<sub>

Subscript: text lowered and shrunk, for example in chemical formulas.

Display
inline
Closing tag
Required
Permitted content
Phrasing content
On this page

Example

#
HTML
<p>Water is H<sub>2</sub>O, and carbon dioxide is CO<sub>2</sub>.</p>
<p>The terms of the sequence: <var>a</var><sub>1</sub>, <var>a</var><sub>2</sub>, …, <var>a</var><sub><var>n</var></sub></p>
Preview

Definition and usage

#

The <sub> element marks a subscript required by notational convention: digits in chemical formulas (H2O), indices in math (x1), or notation in physics. Browsers lower and shrink such text.

Use it only when the position of the text carries meaning, as in the formula H<sub>2</sub>O. If you want to lower text purely for decoration, use CSS: vertical-align: sub.

Subscripts slightly increase the height of the line they’re in, which can make the spacing in a paragraph uneven. A popular fix in CSS is sub, sup { line-height: 0; }.

Syntax

#
Syntax
H<sub>2</sub>O

Attributes

#

This element has no attributes of its own. It supports the global attributes, such as class, id and hidden.

Default CSS

#

Most browsers display this element with these default styles:

CSS
sub {
  vertical-align: sub;
  font-size: smaller;
  line-height: normal;
}

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Use <sub> only when lowering the text changes the meaning of the notation.
  • If subscripts and superscripts push lines of text apart, set line-height: 0 in CSS for sub and sup.
  • Write complex math formulas in MathML.

Related entries

#

Spotted a mistake or missing an example? Write to us.