Text Formatting Elements

TagDescriptionExample
<b>Bold textThis is bold
<strong>Important textThis is strong
<i>Italic textThis is italic
<em>Emphasized textThis is emphasized
<mark>Marked/highlighted textThis is marked
<small>Smaller textThis is small
<del>Deleted textThis is deleted
<ins>Inserted textThis is inserted
<sub>Subscript textH2O
<sup>Superscript textE=mc2

Code Example

<p>This is <b>bold</b> and this is <strong>strong</strong>.</p>
<p>This is <i>italic</i> and this is <em>emphasized</em>.</p>
<p>Do not forget to buy <mark>milk</mark> today.</p>
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>
<p>This is <sub>subscript</sub> and this is <sup>superscript</sup>.</p>

Best Practices

  • Use <strong> instead of <b> for semantic importance
  • Use <em> instead of <i> for semantic emphasis
  • Avoid using formatting tags for layout purposes (use CSS instead)
  • Combine formatting tags carefully (avoid excessive nesting)
  • Remember that some tags have semantic meaning beyond visual appearance

Accessibility

  • Screen readers may announce <strong> and <em> differently
  • Don't rely solely on formatting to convey meaning
  • Ensure proper color contrast for <mark> elements
  • Use <del> and <ins> for document edits/changes