HTML <sub> Element

The HTML <sub> element represents subscript text that is displayed lower than the surrounding text according to established typographical conventions.

Syntax

<p>The chemical formula for water is H<sub>2</sub>O.</p>

The <sub> element requires both an opening and closing tag. Browsers normally display its contents using a smaller font positioned below the normal text baseline.

Attributes

The <sub> element supports the global HTML attributes. It does not have any element-specific attributes.

Example

This example uses the <sub> element to correctly display the numbers in several common chemical formulas as subscript text.

Play in Editor

Usage Notes

Use the <sub> element when text needs to appear as subscript because of a recognized typographical convention rather than simply to create a visual effect.

Common uses include numbers in chemical formulas, variables in mathematical expressions, and other notation that conventionally appears below the normal text baseline.

The <sub> element should not be used solely to make text smaller or move it downward. Use CSS when the desired change is purely presentational.

For text that conventionally appears above the normal baseline, use the <sup> element instead.

For complex mathematical expressions, MathML may provide more appropriate semantic markup than combining ordinary text with <sub> and <sup> elements.

Accessibility

Use the <sub> element only when the lowered text position is meaningful to the notation being presented. This helps preserve the intended structure instead of using CSS alone to imitate subscript text.

Make sure the surrounding content provides enough context for users to understand the notation. For specialized scientific or mathematical expressions, additional explanation may be helpful when the meaning is not obvious.

Browser Support

Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.

For detailed browser compatibility information, see Can I Use: HTML <sub> Element .

The <sub> element is closely related to the <sup> element for superscript text and the <math> element for mathematical expressions using MathML.

Specifications

HTML Living Standard: The <sub> Element