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
| Attribute | Description |
|---|---|
class | Assigns one or more class names for styling. |
id | Assigns a unique identifier to the element. |
style | Adds inline CSS styles to customize appearance. |
title | Provides 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 <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
Use our TryIt Editor to see the output.
Browser Support
Chrome | Firefox | Edge | Safari | Opera | 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.