How to define subscripted text in HTML5?

In this article, we define subscripted text in HTML by using the sub Element in the Document.This tag is used to add a subscript text to the HTML document. The <sub> tag defines the subscript text. Subscript text appears half a character below the normal line and is sometimes rendered in a smaller font. Subscript text can be used for chemical formulas, like H2O to be written as H2O.
Syntax:

<sub> ----- content--- </sub>

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<body>
    <h2>GeeksForGeeks</h2>
    <h2>Hiw to define subscripted Text</h2>
    <p>Testing <sub>subscript text</sub></p
    <p>Testing <sup>superscript text</sup></p
</body
  
</html>                     

chevron_right


Output:

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <style
        sub { 
            vertical-align: sub; 
            font-size: small; 
        
    </style
</head
  
<body
    <p>A sub element is displayed like this</p
    <p>This text contains <sub>subscript text</sub></p
    <p>Change the default CSS settings to see the effect.</p
</body
  
</html

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.