Skip to main content

HTML Text Formatting

HTML has several elements for giving text a special meaning, such as bold, italic, or highlighted text.

Example

Bold, italic, and subscript/superscript text.

Prompt
A page showing formatted text: a bold line, an italic line, and a line containing both subscript and superscript text.
Output: complete HTML page

HTML Formatting Elements

Formatting elements show special types of text: <b> for bold, <strong> for important text, <i> for italic, <em> for emphasized text, <mark> for marked text, <small> for smaller text, <del> for deleted text, <ins> for inserted text, <sub> for subscript, and <sup> for superscript.


HTML <b> and <strong> Elements

The <b> element makes text bold without giving it any extra importance. The <strong> element marks text as important, and its content is usually shown in bold too.

Bold text

Bold text with <b>.

Prompt
A page with bold text using the b element: "This text is bold".
Output: complete HTML page

Important text

Important text with <strong>.

Prompt
A page with important text using the strong element: "This text is important!".
Output: complete HTML page

HTML <i> and <em> Elements

The <i> element marks text in an alternate voice or mood, usually shown in italic; it is often used for a technical term, a phrase in another language, a thought, or a ship name. The <em> element marks emphasized text, also usually italic; a screen reader will say <em> text with verbal stress.

Italic text

Italic text with <i>.

Prompt
A page with italic text using the i element: "This text is italic".
Output: complete HTML page

Emphasized text

Emphasized text with <em>.

Prompt
A page with emphasized text using the em element: "This text is emphasized".
Output: complete HTML page

HTML <small> Element

The <small> element makes text smaller.

Example

Smaller text with <small>.

Prompt
A page with smaller text using the small element: "This is some smaller text."
Output: complete HTML page

HTML <mark> Element

The <mark> element marks or highlights text.

Example

A highlighted word with <mark>.

Prompt
A page with a highlighted word using the mark element: "Do not forget to buy milk today." where milk is marked.
Output: complete HTML page

HTML <del> Element

The <del> element marks text that has been deleted from a document. Browsers usually strike a line through it.

Example

Deleted text with <del>.

Prompt
A page using the del element to show deleted text: "My favorite color is blue red." where blue is struck through.
Output: complete HTML page

HTML <ins> Element

The <ins> element marks text that has been inserted into a document. Browsers usually underline it.

Example

Deleted and inserted text together.

Prompt
A page using both del and ins: "My favorite color is blue red." where blue is deleted and red is inserted (underlined).
Output: complete HTML page

HTML <sub> Element

The <sub> element makes subscript text, which sits half a character below the normal line and is sometimes smaller. It is useful for things like chemical formulas, such as H2O.

Example

Subscript text with <sub>.

Prompt
A page using the sub element for subscript text: "This is subscripted text."
Output: complete HTML page

HTML <sup> Element

The <sup> element makes superscript text, which sits half a character above the normal line and is sometimes smaller. It is useful for things like footnotes.

Example

Superscript text with <sup>.

Prompt
A page using the sup element for superscript text: "This is superscripted text."
Output: complete HTML page

HTML Text Formatting Elements

A quick reference of the formatting tags: <b> bold text, <em> emphasized text, <i> alternate voice or mood, <small> smaller text, <strong> important text, <sub> subscript, <sup> superscript, <ins> inserted text, <del> deleted text, and <mark> marked or highlighted text.