Introduction
The <sub>
element in HTML is used to define subscript text. Subscript text appears slightly below the normal baseline and is typically used for footnotes, chemical formulas, mathematical expressions, or any text that needs to be displayed in a smaller size below the regular text.
Here’s an example of how you might use the <sub>
element:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subscript Example</title>
</head>
<body>
<p>The chemical formula for water is H<sub>2</sub>O.</p>
</body>
</html>
Output:
In this example, the <sub>
element is used to represent the subscript “2” in the chemical formula for water (H₂O), indicating the number of hydrogen atoms. When rendered in a browser, the “2” will appear slightly below the baseline of the surrounding text.