Description

The <sub> (short for subscript) tag renders enclosed text as subscript. Subscript text appears half a character's height below the baseline, and is most often used in mathematical (e.g. y = logax) or chemical formulas, like H2O.

The following table summarizes the usages context and the version history of this tag.

Placement:Inline
Content:Inline and text
Start/ End Tag:Start tag: required, End tag: required
Version:HTML 3.2, 4, 4.01, 5

Usage Notes:

  • ]The <sub> tag should be used for typographical reasons only.
  • This tag must not be used for styling purpose like changing the vertical position of the text. In that case CSS should be used instead: the vertical-align property with the sub value will achieve the same effect.

Syntax

The basic syntax of the <sub> tag is given with:

HTML/XHTML: <sub> ... </sub>

The example below shows the <sub> tag in action.

<p>The chemical formula of Water is: H<sub>2</sub>O</p>
<p>The chemical formula of Carbon Dioxide is: CO<sub>2</sub></p>

Note: The <sub> is identical in purpose to the <s> tag, which also specifies that the enclosed text should be rendered a line through it.

Tag-Specific Attributes

The <sub> tag doesn't have any specific attribute.

Global Attributes

Like all other HTML tags, the <sub> tag supports the glodelal Attributes in HTML5.

Event Attributes

The <sub> tag also supports the event Attributes in HTML5.

Browser Compatibility

Element
<sub>YesYesYesYesYes