Open In App
Related Articles

HTML <sub> Tag

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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
  • Edge 12 and above
  • Internet Explorer 
  • Mozilla Firefox 1 and above
  • Safari
  • Opera


Last Updated : 19 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads