Superscript & Subscript in HTML
Superscript and subscript are useful when writing mathematical expressions, chemical formulas, footnotes, and other content where text needs to be slightly above or below the normal line.
Superscript Text
Use the <sup>
tag to raise text above the baseline.
<p>E = mc<sup>2</sup></p>
Superscript is often used for exponents or footnotes like Note<sup>1</sup>
.
Subscript Text
Use the <sub>
tag to lower text below the baseline.
<p>H<sub>2</sub>O is the chemical formula for water.</p>
Subscript is commonly used in chemical formulas or mathematical notations.
When to Use
- Mathematical powers and indices (
x<sup>2</sup>
) - Chemical formulas like
CO<sub>2</sub>
- Footnotes and citations
Conclusion
Superscript and subscript tags provide semantic meaning and visual clarity when representing technical content. Use them where appropriate to improve comprehension.