<sub>
Subscript: text lowered and shrunk, for example in chemical formulas.
- Display
- inline
- Closing tag
- Required
- Permitted content
- Phrasing content
Example
#<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>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
#H<sub>2</sub>OAttributes
#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:
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: 0in CSS forsubandsup. - Write complex math formulas in MathML.
Related entries
#- <sup>Superscript: text raised and shrunk, for example exponents and footnote numbers.
- <var>A variable in a math formula or a program, as well as a placeholder symbol in a command.
- <small>Fine print: disclaimers, legal notices, copyright, and short side notes.
- <code>A piece of computer code: the name of a variable, function, tag, or file, as well as a short listing.
Spotted a mistake or missing an example? Write to us.