<sub>

The HTML <sub> element presents text as subscript, placing it lower than the baseline. It is commonly used in contexts like chemical formulas or mathematical expressions.

<sub> Tag

The <sub> tag in HTML defines subscript text, positioning it lower than the baseline of surrounding text. It is frequently used in chemical formulas, mathematical equations, and similar notations.

Syntax

index.html
<sub>Subscripted Text</sub>

sub Demo

Subscript text example:

The sub and sup elements

This text contains subscript text.

This text contains superscript text.

index.html
<h1>The sub and sup elements</h1>
<p>This text contains <sub>subscript</sub> text.</p>
<p>This text contains <sup>superscript</sup> text.</p>

Definition and Usage

The <sub> tag formats text as subscript, placing it slightly below the normal text line and typically reducing its font size. A common example is its use in chemical notations like H₂O.

To create superscript text, use the <sup> tag.

Attributes

  • <sup> – Used for superscript text.
  • MathML elements like <msub>, <msup>, and <msubsup> provide advanced mathematical notation.
  • The CSS vertical-align property can be used to adjust text positioning.

Conclusion

The <sub> tag is useful for displaying subscript text in scientific, mathematical, and technical content. It ensures proper formatting in cases such as chemical formulas (e.g., H₂O). To create superscript text, the <sup> tag should be used instead. Both elements contribute to precise content formatting and improved readability.