Definition
The <sup>
HTML element is used to represent superscript text within a line of text. It is commonly used to display mathematical exponents, footnotes, or any content that needs to be placed above the normal text baseline.
Here’s an example of how to use the <sup>
element:
<p>E = mc<sup>2</sup></p>
In this example, the number “2” is wrapped within the <sup>
element. When rendered, the superscript text will appear slightly smaller and positioned above the baseline of the surrounding text, indicating that it represents the exponent in the famous equation E = mc².
The <sup>
element can also be used for other purposes, such as displaying footnotes:
<p>This is an example sentence.<sup>[<sub>1</sub>]</sup></p>
In this case, the <sup>
element is used to create a superscript footnote marker, typically indicating that a corresponding footnote exists at the bottom of the page. The <sub>
element is nested within the <sup>
element to create a subscript effect within the superscript.
It’s important to note that the <sup>
element is primarily used for styling purposes and does not convey any specific semantic meaning. If you require semantic meaning, it is recommended to use more appropriate elements, such as <sub>
for subscript text or <figure>
and <figcaption>
for detailed explanations or descriptions.