Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Inline Text

The <sub> element

Reference for the HTML <sub> element: subscripts in chemical formulas, math indexes and footnote styles, how it differs from <sup>, examples and technical details.

The <sub> element marks text that must appear as a subscript because of a typographic convention: the numbers in chemical formulas, indexes on variables, or certain abbreviations. The browser lowers the text below the baseline and makes it smaller.

HTML
<p>Plants absorb CO<sub>2</sub> and release O<sub>2</sub>.</p>

Try it

Subscripts

The last line uses subscripts to show the number base: 1011 in binary is 11 in decimal.

Attributes

This element has no attributes of its own. It accepts the global attributes.

Usage notes

  • Meaning, not decoration. Use <sub> only where the position changes or carries meaning, as in H2O. To lower text for design reasons, use CSS vertical-align: sub.
  • <sub> vs <sup>. <sup> raises text instead, for exponents, ordinals in some languages and footnote markers.
  • Serious math. For anything beyond simple indexes, such as fractions, roots or stacked limits, use MathML, which lays out formulas properly and is read better by assistive technology.
  • Line spacing. Subscripts can push lines apart. A common fix is sub { line-height: 0; } or font-size: 0.75em; vertical-align: -0.25em;.
  • Accessibility. Screen readers may read "CO2" as "C O 2" with no hint of the subscript. In most cases that is fine; when it is not, explain it in the text.

Technical summary

Content categories Flow content, phrasing content, palpable content
Permitted content Phrasing content
Tag omission None; both the start and end tags are required
Permitted parents Any element that accepts phrasing content
Implicit ARIA role subscript
DOM interface HTMLElement
Default display inline (with vertical-align: sub and font-size: smaller)

Browser support

Supported in every browser.