HTML Text Formatting
HTML provides several elements for defining text with a special meaning, allowing you to format text for emphasis, importance, and more.
Example
This text is bold
This text is italic
This is subscript and superscript
HTML Formatting Elements
Formatting elements were designed to display special types of text. Here is a list of the formatting elements we will cover:
<b>- Bold text<strong>- Important text<i>- Italic text<em>- Emphasized text<mark>- Marked text<small>- Smaller text<del>- Deleted text<ins>- Inserted text<sub>- Subscript text<sup>- Superscript text
HTML <b> and <strong> Elements
The <b> HTML element defines bold text, without conveying any extra importance.
<b>This text is bold</b>The <strong> HTML element defines text with strong importance. The content inside is typically displayed in bold by browsers and read with emphasis by screen readers.
<strong>This text is important!</strong>HTML <i> and <em> Elements
The <i> element defines a part of text in an alternate voice or mood, often used for technical terms, phrases from other languages, or thoughts. The content is typically displayed in italic.
<i>This text is italic</i>The <em> element defines emphasized text. Screen readers will pronounce the words in <em> with an emphasis.
<em>This text is emphasized</em>HTML <small> Element
The <small> element is used to define smaller text, like copyright notices or side-comments.
<p>This is <small>smaller</small> text.</p>HTML <mark> Element
The <mark> element defines text that should be marked or highlighted for reference or notation purposes.
<p>Do not forget to buy <mark>milk</mark> today.</p>HTML <del> and <ins> Elements
The <del> element defines text that has been deleted from a document. Browsers usually render this with a strikethrough.
The <ins> element defines a text that has been inserted into a document. Browsers typically underline this text.
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>HTML <sub> and <sup> Elements
The <sub> element defines subscript text. It appears half a character below the normal line and is useful for chemical formulas like H2O.
<p>This is <sub>subscripted</sub> text.</p>The <sup> element defines superscript text. It appears half a character above the normal line and is useful for footnotes or mathematical exponents like E = MC2.
<p>This is <sup>superscripted</sup> text.</p>Test Yourself with an Exercise
Two of the following HTML elements makes the text bold, which two?
HTML Text Formatting Elements
| Tag | Description |
|---|---|
<b> | Defines bold text |
<strong> | Defines important text |
<i> | Defines a part of text in an alternate voice or mood |
<em> | Defines emphasized text |
<small> | Defines smaller text |
<mark> | Defines marked/highlighted text |
<del> | Defines deleted text |
<ins> | Defines inserted text |
<sub> | Defines subscripted text |
<sup> | Defines superscripted text |