Curriculum ▸ HTML Zero → Mastery ▸ Lesson 23: Subscript (<sub>) Foundations

Lesson 23 — Subscript <sub>

Learning Goals

Part 1 — What is <sub>?

<sub> marks subscript text—characters positioned slightly below the baseline and often rendered smaller. Use it for chemical formulas (H2O), indices (an), and specialized notation.

Part 2 — Minimal Examples

<p>Water: H<sub>2</sub>O</p>
<p>Carbon dioxide: CO<sub>2</sub></p>
<p>Sequence term: a<sub>n</sub> = a<sub>n-1</sub> + d</p>

Result: The 2s and the n are lowered as subscripts.

Part 3 — Best Practices

Part 4 — Accessibility Notes

Most screen readers read subscript as normal text. Provide context in surrounding copy (e.g., “the formula for carbon dioxide, CO2”). If subscripts encode critical meaning, consider clarifying textually as well.

Practice Tasks

  1. Create lesson-23/index.html and write CO2, H2O, and an correctly.
  2. Add an equation mixing <sub> and <sup> (e.g., x2 + y1).
  3. Explain—right in the page—what each subscript conveys.

Quick Quiz

  1. What is <sub> meant to represent semantically?
  2. Give one valid scientific example and one math example.
  3. Why not use <sub> for disclaimers/footnotes?
Sample answers
  • Subscript text (lowered below baseline) with domain meaning.
  • CO2 in chemistry; an in sequences.
  • Because that’s <small> content or CSS styling—not a subscript concept.

Lesson 23 Dictionary

Accessibility (context)
Clarifying meaning in surrounding text so subscripts aren’t ambiguous to assistive tech.
Baseline
The invisible line on which most letters sit; subscript text is lowered below this line.
Chemical formula
Notation for compounds that often uses subscripts to indicate atom counts (e.g., CO2).
Index (math)
A subscript used to label terms in a sequence or components (e.g., an).
Meaning (semantics)
The idea that <sub> conveys domain meaning (not just visual decoration).
<sub> (Subscript)
HTML element that renders text as subscript for formulas, indices, and specialized notation.