Tag sub In HTML

This post focuses on the HTML Tag <sub> with examples. With the optimism that it would help us all learn.

The <sub> tag is an HTML element used to create subscript text. It is typically used to display mathematical or chemical formulas, footnotes, or abbreviations.


The <sub> tag specifies subscripted text. The subscripted font is typically half a character thinner than the normal font, and it appears half a character below the normal line. Chemical formulas, like H2O, can be written in subscripts.

Advice: Specify the <sup> tag to describe superscripted text.

Subscript text formula example:


<!DOCTYPE html> <html> <body> <p>The chemical formula for water is H<sub>2</sub>O</p> </body> </html>

An example would be creating a mathematical expressions with multiple subscripts and superscripts like this:


<!DOCTYPE html> <html> <body> <p>E = mc<sup>2</sup> = (m<sub>0</sub> + m<sub>1</sub> + m<sub>2</sub> + … + m<sub>n</sub>)c<sup>2</sup></p> </body> </html>

The <sub> tag in HTML to create a unique element on a webpage is to create a legal disclaimer or terms of service section:


<!DOCTYPE html> <html> <body> <p>By using our Mr Examples, you agree to our <sub><a href="terms.html">Terms of Service</a></sub></p> </body> </html>

CSS can also be applied to the <sub> tag here is how:


<!DOCTYPE html> <html> <head> <style> sub:hover { text-decoration: underline; color: maroon; } </style> </head> <body> <p>The chemical formula for water is H<sub>2</sub>O</p> </body> </html>

Tag <sub> Uses

The <sub> tag in HTML has several uses, including:

  • The <sub> tag is commonly used to display subscript text in mathematical formulas. For example, the chemical formula for water (H2O) uses the <sub> tag to display the subscript “2” for the number of hydrogen atoms.
  • The <sub> tag can also be used to display footnote markers in text. For example, you might use a subscript “1” to mark the first footnote in a document.
  • The <sub> tag can be used to display subscript text for abbreviations or acronyms. For example, you might use a subscript “TM” to indicate a trademark symbol.
  • The <sub> tag is also commonly used to display subscript text in chemical formulas. For example, the molecular formula for carbon dioxide (CO2) uses the <sub> tag to display the subscript “2” for the number of oxygen atoms.



Additionally, the <sub> tag is compatible with HTML Global Attributes.


In HTML, Event Attributes are also accepted by the HTML tag sub <sub>.

Browser Compatibility

<sub> Yes Yes Yes Yes Yes

Predefined CSS

Often browsers will show the following defaults values for the <sub> element:

sub {
vertical-align: sub;
font-size: smaller;

HTML Sub Tag Benefits

The <sub> tag in HTML provides several benefits, including:

  • The <sub> tag can be used to create subscript text, which can improve the readability of certain types of content. For example, in mathematical equations or chemical formulas, subscript text is often used to indicate the number of atoms or molecules. By using the <sub> tag, you can make this information more visually distinct and easier to read.
  • The <sub> tag provides semantic meaning to your content. By using the <sub> tag to create subscript text, you are indicating to web browsers and assistive technologies that this text is intended to be displayed in a subscript format. This can improve the accessibility of your content for users who rely on screen readers or other assistive technologies.
  • The <sub> tag can help you maintain consistency in your formatting. By using the <sub> tag to create subscript text, you can ensure that this text is always formatted in the same way across your website or web application.
  • By using HTML tags like <sub> to format your content, you are separating the content from the presentation. This can make it easier to maintain and update your website or web application over time.
To share article with your friends do click the social media links below.

We value your feedback.

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!

Leave a Reply

Your email address will not be published. Required fields are marked *