HTML <sub> Tag

In this chapter we will speak about <sub> tag. When do we use it?

We know that for text, we use the <p> tag.

As you remember the <p> tag comes in pairs.

Let's see example.

<!DOCTYPE html>
<html>
   <head>
      <title>Title of the document</title>
   </head>
   <body>
      <p>Some text which we want to show</p>
   </body>
</html>

Here is the result.


The <sub> tag also comes in pairs. As you know it means that we need to open the tag( <sub>) and close it (</sub>).

Now we will show the example, where we type some text, which will be shown with a smaller font size and a little lower than the normal text. That information we will type between the opening and closing tag.

Let's see the example.

<!DOCTYPE html>
<html>
   <head>
      <title>Title of the document</title>
   </head>
   <body>
      <p>Some text which we want to show <sub>smaller text</sub>.</p>
   </body>
</html>

Here is the result.

The <sub>< tag can be useful in some sciences like chemistry.

Let's see the example.

We will type the chemical formula of water. As you know the formula of water is H2O. Now see the code example below: the <sub> tag let us write number 2 bellow the letter "H".

<!DOCTYPE html>
<html>
   <head>
      <title>Title of the document</title>
   </head>
   <body>
      <p>H<sub>2</sub>O.</p>
   </body>
</html>

Here is the result.