Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Text Content  ›  Lesson

mark, sub and sup

mark 12 minmark highlights text that is relevant in the current context, while sub and sup lower or raise characters whose position is part of their meaning, as in chemical formulas and exponents.

mark, sub and sup

A few elements exist for very specific jobs: highlighting a match, writing a chemical formula, showing an exponent or a footnote number. They are small, but using them correctly makes text precise instead of approximate.

The rule

mark shows relevance right now; sub and sup move characters that mean something.

<mark> highlights text because it is relevant in the current context, like a highlighter pen on a printed page. The classic use is showing search matches:

<p>Results for "monsoon": The <mark>monsoon</mark> reaches Kerala in early June.</p>

mark is not "important" (that is strong) and not "stressed" (that is em). It says "look here, this is what you are after".

<sub> lowers text below the baseline: subscript. <sup> raises it: superscript. Use them when the position is part of the meaning.

<p>Water is H<sub>2</sub>O.</p>
<p>The area is 25 m<sup>2</sup>.</p>
<p>E = mc<sup>2</sup></p>
<p>This claim needs checking.<sup><a href="#note-1">1</a></sup></p>

Without sub, "H2O" would be a different, looser notation. Without sup, "m2" does not mean square metres to a careful reader. Footnote markers are also commonly written with sup.

Do not use sub or sup just to make text smaller or shift it for decoration; that is a job for CSS.

The shortcut

Ask one question for each: "If I moved or unhighlighted this, would the meaning change?"

Marking up "CO2 levels rose 3 x 10^2 ppm"Step 1 of 4
  1. The 2 in CO2

    In a chemical formula the 2 belongs below the line. CO<sub>2</sub>.

The trap is using mark as a general highlighter for important text. If it is important everywhere, not just in this context, it is strong.

All three are inline elements, so they sit inside a paragraph, heading or list item and never start a new line. sub and sup can also hold more than one character, such as x<sup>n+1</sup> for a longer exponent. For heavy mathematics, dedicated tools like MathML exist, but for a unit, a formula or a footnote number these two are exactly right.

Drills

Answer fast — trust the rule.

quick drill

How do you write the formula for carbon dioxide correctly?

quick drill

Which element fits the "3" in "x cubed" written as a power?

quick drill

A document viewer highlights every place the word "invoice" appears after you search for it. Which element fits?

quick drill

A heading says "Final notice" and must stand out as urgent on every visit. Should you use <mark>?

Remember

  • mark = relevant in this context; sub = lowered, sup = raised, when position carries meaning.
  • Shortcut: would moving or unhighlighting it change the meaning? If not, it is CSS.
  • Trap: mark for general importance; sub/sup for decoration.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainExplain a highlighted search result

A search page shows the result 'Water is H2O' for the query 'H2O', with the query highlighted and the 2 lowered. Write the HTML for that sentence and explain why each element was chosen.