HTML SUB AND SUPER SCRIPT TEXT


HTML Subscript Text

To make a text be displayed as subscript we need to use the

<sub> element.

Subscripts are usually rendered with a lowered baseline and smaller text.

Warning! The sub element should only be used for typographical reasons not for appearance purposes.

Example:

<! DOCTYPE html> 

<html> 

        <head>

            <title> Subscript T </title>

        </head>

        <body>

           <p>N<sub>2</sub> + H <sub>2</sub> = NH <sub>3</sub> </p>

           <p>N<sub>2</sub> + H <sub>2</sub> = 2NH <sub>3</sub> </p>

        <body>

<html>

Output:

N2 + H2 = NH3

N2 + H2 = 2NH3


HTML Superscript Text

To make a text be displayed as superscript we need to use the

<sup> element. Superscripts are usually rendered with a raised baseline and smaller text.

A Warning! The sup element should only be used for typographical reasons not for appearance purposes.

Example:

<! DOCTYPE html> 

<html> 

        <head>

            <title> Superscript Text</title>

        </head>

        <body>

               <p> = (X+2) (x<sup>2</sup>+3) </p>

        <body>

<html>

Output:

= (x+2) (x²+3)