HTML – Subscript in HTML and SUP (Superscript)

SUB (Subscript) and SUP (Superscript) Tags

Subscript in HTML

The tag <sub> is defined as subscript in html.  It is widely used to place subscripted text on web pages.

It is a paired tag. It has a start tag <sub> and closing tag </sub> Subscript text appears half a character below the normal line and is sometimes rendered in a smaller font.

We can see on science-related websites Subscript is used to write chemical compounds. Example.  H2O O2 H2SO4

HTML Example

This Text is<sub>Sub-scripted</sub>Text.

HTML Output

This Text is Sub-scripted Text.

HTML Example 2

<p>H<sub>2</sub>O</p>
<p>O<sub>2</sub></p>
<p>H<sub>2</sub>SO<sub><4/sub></p>

HTML Output 2

H2O
O2
H2SO4

HTML <sup> Tag.

The <sup> tag is used to define the superscript text on web pages. Superscript and Subscript are often used in mathematical expression and chemical compounds.

The Superscript tag can be modified by using CSS, by defining id we will talk more in CSS Tutorial.

Sometimes the superscript text can be used on the footer side and to reference. We can see wide use of superscripts in Wikipedia.

HTML Example

(a+b)<sup>2 </sup>= a<sup>2</sup>+2ab+b<sup>2</sup>

HTML Output

(a+b)2 = a2+2ab+b2

Try By Yourself

(a-b)2=a2 – 2ab + b2 a2-b2=(a+b)(a-b)