HTML sub Tag

Last Updated : 3 Apr, 2026

The <sub> tag in HTML defines subscript text, displayed smaller and below the normal text baseline, commonly used in chemical formulas, mathematical expressions, and footnotes (e.g., H₂O or E=mc²).

HTML
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <h1>Using the &lt;sub&gt; Tag in HTML</h1>
    <p>Chemical formula example: H<sub>2</sub>O</p>
    <p>Mathematical expression example: E = mc<sub>2</sub></p>
    <p>Footnote example: Water molecule contains two hydrogen atoms<sub>1</sub></p>
</body>
</html>

Syntax:

<sub> Contents. . . </sub>

There are no such attributes that apply specifically to this <sub> tag. The attributes that only apply to this tag are global attributes.

Example 1: In this example, the <sub> tag is used to create subscript text. The "2" in the chemical formula "H₂O" is displayed as smaller and slightly lower than the baseline, indicating the number of hydrogen atoms.

HTML
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body style="text-align: center;">
    <h1 style="color: green;"> GeeksforGeeks </h1>
    <h2>Chemical Formula of Water</h2>
    <h2>H<sub>2</sub>O</h2>
</body>
</html>

Output:

Example 2: In this example the <sub> tag is used to display subscript text. It renders the "n" in the mathematical expression "xₙ + yₙ" smaller and below the baseline, indicating a variable's subscript.

HTML
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body style="text-align: center;">
    <h1 style="color: green;"> GeeksforGeeks </h1>
    <h2>Mathematical Formula</h2>
    <h2>x<sub>n</sub> + y<sub>n</sub></h2>
</body>
</html>

Output:

Comment