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

<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

<!DOCTYPE html>
<html>
<head>
  <title>SUB Tag Example</title>
  <style>
    .chemical {
      color: #2c3e50;
      font-size: 0.9em;
    }
  </style>
</head>
<body>
  <h1>HTML &lt;sub&gt; 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

Use our TryIt Editor to see the output.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

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.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend