The HTML <sub> element marks subscript text and <sup> marks superscript text when the vertical position has semantic meaning, such as chemical formulas, exponents, footnote markers or ordinals.
<p>Water: H<sub>2</sub>O</p>
<p>Area: x<sup>2</sup></p>Water: H2O
Area: x2
If you only need to move text visually, use CSS. <sub> and <sup> should represent content that conventionally appears below or above the baseline.
<p>E = mc<sup>2</sup></p>
<p>CO<sub>2</sub></p>
<p>1<sup>st</sup> place</p>
Subscript text such as the 2 in H2O.
Superscript text such as an exponent or footnote marker.
No. Their purpose is semantic subscript/superscript placement.
Yes.
Yes, they are phrasing elements.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
02-12-2020 | |
| VERY NICE | |