HTML <sup>
Tag
The <sup>
tag is used in HTML to define superscript text. Superscript text appears half a character above the normal line of text. It is commonly used for mathematical exponents, footnotes, and annotations.
Here is an example of how the <sup>
tag is used:
<p>2<sup>3</sup></p>
Output:
23
In the example above, the number 3 is displayed as a superscript, indicating that it is an exponent of the number 2.
Main Attributes of the <sup>
Tag
Attribute | Description |
---|---|
style | Specifies CSS styles to be applied to the superscript text |
class | Specifies one or more class names for the element (referring to a class in a CSS stylesheet) |
Here is an example of how the <sup>
tag can be used with the style
attribute:
<p>E=mc<sup style="font-size: 10px;">2</sup></p>
Output:
E=mc2
In the example above, the number 2 is displayed as a superscript with a smaller font size.
Remember to always use the <sup>
tag for indicating elements that should be displayed as superscript in your HTML document.