HTML <sub> Tag Tutorial - Usage, Syntax,
Attributes and Example

calender-iconPublished: 15 May 2025

clock-icon5-min read





INTRODUCTION

The HTML <sub> element is used to make text appear as subscript. According to Merriam-webster Dictionary subscript is a distinguishing symbol (such as a letter or numeral) written immediately below or below and to the right or left of another character

In HTML the subscript is shown by browser with lower baseline and smaller font-size. It is mostly used for typographical (design or style of writing text) conventions of language and not for appearance purposes. The below image will make it clear.

subscript & superscript

Common use cases are as follows.

  • Mathematical variables - In mathematical coordinate system, the points on coordinate axes are represented x1 -- xn where numbers are written as subscripts.
  • Chemical formulas - In chemistry the number of atoms of an element is written as subscripts. for example: H2O
  • footnote numbers - They are small numbers that appears in text. They correspond to additional information or cite the source which is provided at bottom of passage for example: annual1.
Syntax:
<sub> - TEXT - </sub>

Example:

<p> The chemical formula of water is H<sub>2</sub>O 
</p>

Output:

The chemical formula of water is H2O



Tag Omission

The HTML <sub> element must have both start tag and end tag.

ATTRIBUTES

The <sub> element only has global attributes.

Frequently Asked Questions (FAQ)

What is the sub tag in HTML?
The sub tag in HTML is used to define subscript text. Subscript text appears half a character below the normal line and is typically rendered in a smaller font.

How do you use the sub tag in HTML?
To use the sub tag in HTML, wrap the text you want to display as subscript inside <sub> and </sub> tags.

Example:
<sub> - TEXT - </sub>

Is it possible to apply both subscript and superscript to a single HTML element?
Yes, you can add both subscript and superscript to the same element in HTML, but you need to nest the sub and sup tags carefully to achieve the desired formatting.

Example:

X<sub>1</sub><sup>2</sup>

X12