# mark, small, sub & sup

> Four small elements that handle highlighter relevance, fine print, and the typographic positions above and below the baseline.

Subject: HTML | Lesson 11 of 42 | 5 min read
Interactive lesson: https://codewithanimation.in/html/mark-small-sub-sup
Previous: [Meaning vs Appearance](https://codewithanimation.in/html/strong-em-vs-b-i.md) | Next: [Edits & Computer Text](https://codewithanimation.in/html/edits-and-computer-text.md)

## What they are

`<mark>` highlights a run of text to show that it is relevant in the current context. The classic use is a search results page that bolds the query term inside each snippet. `<mark>` is not a synonym for `<strong>`: it does not signal importance, it signals relevance to whatever the reader is doing right now.

`<small>` carries text that is a side comment or fine print. License footers, copyright lines, legal caveats, and inline disclaimers all belong in `<small>`. It signals reduced importance in the document's voice, not a smaller font size for layout.

`<sub>` and `<sup>` position text below or above the baseline at a smaller size. `<sub>` is for subscripts: chemical formulas like H₂O, the base in logarithm notation. `<sup>` is for superscripts: mathematical exponents like x², ordinal suffixes like 1ˢᵗ, and footnote reference numbers.

## Why it matters

`<mark>` can be announced by screen readers as highlighted text, which helps users who are scanning a page for search matches or annotations. Using a `<span>` with a yellow background looks the same visually but loses that announcement.

`<sub>` and `<sup>` exist because simulating superscript with a regular span and `font-size: smaller; vertical-align: super` requires CSS you have to maintain and rarely lands in exactly the right position. The elements encode the intent and let the browser handle the metrics, which matters especially inside flowing text.

## How it works

`<mark>` renders with a browser-default yellow or orange highlight background. You can override the color with CSS `background-color` and `color`. Wrap only the specific run of text that is relevant, not the whole sentence.

`<small>` reduces the font size one step (to `0.8em` by default) and signals fine-print semantics. It should wrap inline side comments, not whole paragraphs of legal text. Use it sparingly.

`<sub>` lowers the baseline and shrinks the text. `<sup>` raises it. Both adjust position and size automatically. Use them for content that is genuinely subscripted or superscripted, such as scientific notation or footnote markers, not for visual tricks. If you only want the look without the meaning, CSS `vertical-align` achieves it without the semantic overhead.

## Common mistake: Using <mark> to mean important instead of relevant

`<mark>` and `<strong>` both make text stand out, but for different reasons. `<mark>` says: this text is relevant to the current task, such as a search query match or a peer-review annotation. `<strong>` says: this text is important or serious. Marking a warning with `<mark>` is a category error: the text is important, not search-relevant. Reserve `<mark>` for the highlight-in-context job it was designed for.

## Tip: Update <mark> dynamically for search highlighting

Because `<mark>` is an inline element, JavaScript can wrap query matches in `<mark>` tags dynamically after a search interaction and remove them when the query clears. This is more semantically correct than toggling a CSS class, and it is exactly the use case the element was designed for.

## Try it: Try it

See `<mark>` highlight a search match, `<small>` render a copyright line, and `<sub>`/`<sup>` position the numbers in a formula and an exponent.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/html/mark-small-sub-sup

## Check yourself

### Question 1

A search page wraps the user's query term inside each result snippet. Which element should wrap the matched text?

- A. <mark>, because the text is relevant to the current search context
- B. <strong>, because it is the most important part of the snippet
- C. <b>, because you want it visually highlighted

Correct answer: A

`<mark>` highlights text that is relevant to the reader's current context, making it the right choice for search matches. Screen readers can announce it as highlighted text.

- Why not B: <strong> signals importance or urgency. The matched term is not important; it is relevant to what the user searched for. That is the job of <mark>.
- Why not C: <b> is a stylistic offset with no semantic weight. <mark> was built specifically for the search-match highlighting use case.

### Question 2

Which of these belongs in a <small> element?

- A. A copyright line at the bottom of a page
- B. A heading that should appear in a smaller font
- C. A safety warning that must not be missed

Correct answer: A

`<small>` marks side comments and fine print: copyright notices, legal disclaimers, and caveats. It signals reduced importance in the document, not a visual size.

- Why not B: <small> is a semantic element for fine print. Changing a heading's font size is a CSS job, not a job for <small>.
- Why not C: That needs <strong>, not <small>. <small> reduces importance; <strong> signals urgency. A safety warning should not be small.

### Question 3

You are writing the chemical formula for water. What markup is correct?

- A. H<sub>2</sub>O
- B. H<sup>2</sup>O
- C. H<small>2</small>O

Correct answer: A

`<sub>` positions text below the baseline, which is correct for atomic counts in chemical formulas. `<sup>` raises text above the baseline and is used for exponents and ordinal suffixes.

- Why not B: <sup> raises the text above the baseline. In chemical formulas the number goes below the baseline, which is <sub>.
- Why not C: <small> signals fine print. It does not position text below the baseline. Only <sub> does that.

## Remember this

- `<mark>` highlights text that is relevant to the current context; it is not a synonym for `<strong>`.
- `<small>` marks fine print and side comments; use CSS for font size changes that carry no semantic meaning.
- `<sub>` lowers text below the baseline (H₂O); `<sup>` raises it above (x², footnote markers).
- All four are inline elements; they affect only the text they wrap, not block layout.
