HTML Text Formatting
HTML has a family of small inline elements for marking up words and phrases inside a sentence: important words, emphasised words, highlighted text, chemical formulas and more. Most of them carry meaning, not just a look.
Bold: <strong> and <b>
Both display bold text by default, but they mean different things:
<strong>marks text of strong importance — a warning, a key fact. Screen readers may announce it with stress.<b>draws attention to text without adding importance — a product name in a review, keywords in a summary.
<p><strong>Warning:</strong> the floor is wet.</p>
<p>The <b>Lumo 3</b> lamp has a soft, warm glow.</p>Italic: <em> and <i>
The same idea applies to italics:
<em>means emphasis — it changes how the sentence would be spoken.<i>marks text in an alternative voice: foreign words, technical terms, thoughts, ship names.
<p>I <em>really</em> need a holiday.</p>
<p>I need a <em>holiday</em>, not a week of meetings.</p>
<p>The phrase <i lang="la">carpe diem</i> means "seize the day".</p>Notice how moving <em> changes the meaning of the second sentence.
Highlighting, small print, edits
<p>Remember to bring <mark>your passport</mark> to the airport.</p>
<p>Ticket: €29 <small>(booking fee not included)</small></p>
<p>Price: <del>€40</del> <ins>€29</ins></p>
<p>This information is <s>up to date</s> outdated.</p><mark>highlights text that is relevant right now, like search matches.<small>is for side comments and fine print.<del>shows text that was removed and<ins>text that was added, for example in a price change or document revision.<s>shows text that is no longer accurate.
Subscript and superscript
<p>Water is H<sub>2</sub>O.</p>
<p>Einstein: E = mc<sup>2</sup></p>
<p>This is the 1<sup>st</sup> edition.<sup>[1]</sup></p><sub> lowers text below the line, and <sup> raises it above. Use them for formulas, exponents, ordinal suffixes and footnote markers.
Formatting reference
| Element | Meaning | Default look |
|---|---|---|
<strong> |
Strong importance | bold |
<b> |
Attention without importance | bold |
<em> |
Stress emphasis | italic |
<i> |
Alternative voice or term | italic |
<mark> |
Highlighted / relevant | yellow background |
<small> |
Side comment, fine print | smaller text |
<del> |
Deleted text | |
<ins> |
Inserted text | underlined |
<s> |
No longer accurate | |
<sub> |
Subscript | lowered |
<sup> |
Superscript | raised |
Combining formatting
Formatting elements can be nested inside each other:
<p>
<strong>Deadline: <em>tomorrow</em></strong> at 9:00
— <mark>no <del>extensions</del> exceptions</mark>.
</p>Tip: Ask yourself "would this sound different if read aloud?" If yes, use
<strong>or<em>. If you only want a visual change, use<b>,<i>or CSS.
Note: The
<u>element exists too, but underlined text is easily mistaken for a link. Use it rarely, e.g. to mark spelling errors.
Test yourself
Which element marks text as strongly important?
<b><strong><mark><big>
How do you write the 2 in H₂O?
<sup>2</sup><small>2</small><sub>2</sub><low>2</low>
Which pair shows an old price being replaced by a new one?
<del>and<ins><em>and<i><sub>and<sup><mark>and<small>