Tuesday, November 11, 2025

What is sub Tag in HTML. Syntax Examples

how to use subscript tag in html


What is the  HTML  SubScript tag

✷ The HTML <sub> tag is used to display text slightly below the normal line. This type of text is called subscript text and is commonly used in chemical formulas, mathematical expressions, and scientific writing.

✷ The syntax of the <sub> tag is very simple:

<sub>text</sub>

✷ When you place text inside the <sub> tag, the browser automatically shows it in a smaller size and lowers it below the baseline. This makes it perfect for writing formulas like water:

✷ H<sub>2</sub>O

✷ This will display as H₂O, which is the correct scientific format.

✷ The <sub> tag is also useful in mathematics, for example:

x₁, x₂, x₃

✷ It is an inline element, meaning it does not start on a new line and can be used inside paragraphs, headings, or other text content without breaking the layout.

✷ There is also a related tag called <sup>, which is used to display text above the line (superscript).

✷ html  subscript tag is use to display text slightly below the normal line of text. it is commonly  use in chemical  formulas , mathematical expressions & scientific


Syntax 


<sub>Text content</sub>

how to use subscript tag in html
Example 

<!DOCTYPE html>
<html>
 <body>
  <h2> how to use subscript tag in html</h2>
<p>student learn <sub> HTML </sub> programming language</p>
    <p> Student learn <sub>CSS</sub> Programming language</p>

 </body>

</html>

how to use subscript tag in html
Explain Program

Step 1 ]

<!Doctype html>

<!doctype html>  always be the first line of any HTML document.

Step 2 ]

   <html> and </html>

   html  is the root element.

Step 3 ]

<body> and </body>

body  is  main content area.

All visible content inside to  the <body> tag
Step 4]

<h2> how to use subscript tag in html</h2>

<h2>  display title create second-level heading  bold  larger text.</h2>

Step 5]

<p>student learn <sub> HTML </sub> programming language</p>
    <p> Student learn <sub>CSS</sub> Programming language</p>

each <P> tag defines  paragraph text.

inside each <p>  tag is a subscript tag (<sub> tag).

Step 6]

<p> Student learn <sub> HTML </sub> programming language</p>

Sub tag  

the <sub> tag is use to display text slightly  below the normal line is subscript tag.
commonly use chemical formulas , mathematical expression 

HTML word appear as subscript tag  a bit lower and smaller than surrounding text.

<p> Student learn <sub> CSS </sub> programming language</p>

CSS word appear as subscript tag  a bit lower and smaller than surrounding text.

Step 7]

closing the Tag

</body>
</html>

how to use subscript tag in html

Output

how to use subscript tag in html

Related Post :-

No comments:

Post a Comment