Horje
HTML <sub> Tag

Definition and Usage

The <sub> tag defines 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.

Tip: Use the <sup> tag to define superscripted text.


Browser Support

Global Attributes

The <sub> tag also supports the Global Attributes in HTML.


Event Attributes

The <sub> tag also supports the Event Attributes in HTML.



How to create HTML <sub> Tag

It subscripts text.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The sub and sup elements</h1>

<p>This text contains <sub>subscript</sub> text.</p>
<p>This text contains <sup>superscript</sup> text.</p>

</body>
</html>

Output should be:

How to create HTML <sub> Tag

How to set Default CSS Settings in HTML <sub> Tag

Most browsers will display the <sub> element with the following default values.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
sub {
  vertical-align: sub;
  font-size: smaller;
}
</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 should be:

How to set Default CSS Settings in HTML <sub> Tag



HTML <sub> Tag Video


html sub

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference