Skip to content
Related Articles

Related Articles

Improve Article

HTML <sub> Tag

  • Last Updated : 14 Dec, 2020
Geek Week

This <sub> tag in HTML is used to write text below the baseline of the text in a smaller font. This tag can be used in many ways like we can denote some mathematical variables in the form of subscript text. We can also use this to denote the number of atoms of a chemical formula like the formula of glucose-c6h12o6.

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:

HTML




<!DOCTYPE html>
<html>
  
<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:

HTML




<!DOCTYPE html>
<html>
  
<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:

Supported Browsers:

  • Google Chrome
  • Internet Explorer 
  • Mozilla Firefox 
  • Safari
  • Opera

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :