totn HTML

HTML: <sub> tag

This HTML tutorial explains how to use the HTML element called the <sub> tag with syntax and examples.

Description

The HTML <sub> tag defines subscript text in an HTML document. For example, in the chemical formula CO2, the number 2 is rendered as subscript which has a smaller font and appears with a lowered baseline. This tag is also commonly referred to as the <sub> element.

Syntax

In HTML, the syntax for the <sub> tag is:

<body>
  <p>People release CO<sub>2</sub> when they breathe out.</p>
</body>

Sample Output


Attributes

Only the Global Attributes apply to the <sub> tag. There are no attributes that are specific to the <sub> tag.

Note

  • The HTML <sub> element is found within the <body> tag.
  • The <sub> tag is used to comply with typographical standards or conventions.
  • The <sub> tag is generally used to specify chemical formulas such as CO2, to mark up footnote numbers such as Footnote1 and to represent variables in mathematical formulas such as xn.

Browser Compatibility

The <sub> tag has basic support with the following browsers:

  • Chrome
  • Android
  • Firefox (Gecko)
  • Firefox Mobile (Gecko)
  • Internet Explorer (IE)
  • Edge Mobile
  • Opera
  • Opera Mobile
  • Safari (WebKit)
  • Safari Mobile

Example

We will discuss the <sub> tag below, exploring examples of how to use the <sub> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.