This reference is built into PageRIJ — a live HTML, CSS & SVG authoring and learning environment.

HTML <sub> element

The <sub> element represents subscript text. It is used when a part of the text is written lower because that lower position carries meaning.

A common example is chemical notation. In H2O, the 2 is not just small decorative text. It changes the meaning of the formula. That is exactly the kind of case where <sub> is appropriate.

Subscripts are also used in mathematics, science, technical writing, and variable names. For example, x1 and x2 can refer to different values in a sequence or family of variables.

The element should not be used simply to push text downward for visual effect. If the lowered position does not change the meaning, use CSS to control the positioning.

For detailed mathematical layout, MathML is more exact. But for small expressions inside prose, <sub> is a practical and readable way to mark a meaningful subscript.

For a variable with an index, combine <var> with <sub>. The second example marks each indexed variable as a whole, with its numeric index lowered inside it.

Attributes: GLOBALS.

Typical layout:
<p>Water is H<sub>2</sub>O.</p>
<p>The first two values are
  <var>x<sub>1</sub></var> and <var>x<sub>2</sub></var>.
</p>
Visual representation:

Water is H2O.

The first two values are x1 and x2.