Skip to content
Related Articles

Related Articles

How to define subscripted text in HTML5?
  • Last Updated : 28 Oct, 2020

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:




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

Output:

Example 2:




<!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

Output:

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :