HTML Tags

HTML <sub> Tag

The <sub> tag in HTML is used to display subscript text, which appears smaller and slightly below the baseline of normal text.
It is commonly used in mathematical formulas, chemical formulas, and footnotes.
It is an inline element.

Syntax

html

<sub>Subscript text</sub>

Attributes

AttributeDescription
classAssigns one or more class names for styling.
idAssigns a unique identifier to the element.
styleAdds inline CSS styles to customize appearance.
titleProvides additional information as a tooltip.

Example

html

<!DOCTYPE html>
<html>
<head>
  <title>SUB Tag Example</title>
  <style>
    .chemical {
      color: #2c3e50;
      font-size: 0.9em;
    }
  </style>
</head>
<body>
  <h1>HTML <sub> Tag Example</h1>
  <p>
    Water chemical formula: H<sub class="chemical" id="water-sub" title="Subscript">2</sub>O
  </p>
  <p>
    Example: CO<sub>2</sub> is carbon dioxide.
  </p>
</body>
</html>

Output

Browser Output

html

Use our TryIt Editor to see the output.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

The <sub> tag displays text slightly below the baseline, often in smaller font size, making it ideal for chemical formulas, footnotes, or mathematical notation.

Notes

  • <sub> is an inline element and does not break the line.
  • CSS can be used to further style subscript text (color, font-size).
  • Often paired with <sup> for superscripts in formulas and citations.
  • Avoid overusing for normal text; it is meant for specialized notation.

Conclusion

The <sub> tag is used for subscript text, commonly in chemical, mathematical, or scientific contexts.
It visually shifts the text below the baseline, ensuring proper formatting for technical content.