<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
<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².
<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
<figcaption> for detailed explanations or descriptions.
In summary, the
<sup> element is used to represent superscript text within a line of text. It is typically used for mathematical exponents, footnotes, or any content that needs to be placed above the normal text baseline. By using the
<sup> element, you can visually distinguish and indicate the position of superscript text within your content.