Inline Text Semantics: Special-Purpose Text Elements
You'll learn how to use four specialized HTML elements that add meaning to small portions of text within your content.
The Core Idea
While <strong> and <em> convey importance and emphasis, HTML provides additional inline elements for specific semantic purposes: highlighting relevant text, displaying legal fine print, and formatting mathematical or chemical notation. These elements describe what kind of text you're marking up, not just how it should look.
The Four Elements
<mark> — Highlighting for Relevance
Use <mark> to highlight text that's relevant to the current context, like search results or reference points. Think of it as a digital highlighter marker.
<p>Your search for "semantics" returned 5 results.
HTML <mark>semantics</mark> help screen readers understand content.</p>
<small> — Fine Print
Use <small> for side comments, legal disclaimers, or copyright notices—content that's less prominent but still necessary.
<p>Free shipping on all orders! <small>Terms and conditions apply.</small></p>
<sub> — Subscript
Use <sub> for subscript text, common in chemical formulas or mathematical notation.
<p>Water's chemical formula is H<sub>2</sub>O.</p>
<sup> — Superscript
Use <sup> for superscript text, like footnote references or mathematical exponents.
<p>Einstein's famous equation is E=mc<sup>2</sup>.</p>
Why Semantics Matter
These elements tell browsers and assistive technologies why the text is different, not just that it looks different. A screen reader might announce highlighted text differently, and <small> indicates less important content.
Key Takeaway: Use <mark> for highlighted relevance, <small> for fine print, <sub> for subscript (like H₂O), and <sup> for superscript (like X²)—each adds specific semantic meaning to inline text.