<sup> Tag in HTML | Superscript Text
The <sup> tag in HTML is used to define superscript text. Superscript text appears smaller than the regular text and is positioned slightly above the normal text. It is commonly used for mathematical expressions, footnotes, and chemical formulas.
Key Points on <sup> Tag:
- The <sup> tag is used to display text in superscript, making it appear above the normal line of text.
- It is often used for mathematical exponents (e.g., x2), chemical formulas (e.g., H2O), and footnotes.
- Text enclosed within the
<sup>
tag will be displayed smaller and raised compared to the normal text. - It is an inline element, meaning it does not start on a new line and will not affect the flow of the surrounding content.
- It can be combined with other text formatting elements, such as
<em>
,<strong>
, and<span>
, to enhance styling.
Syntax of <sup> Tag:
Syntax Example
<sup>Superscript Text</sup>
Example of <sup> Tag in HTML:
This example demonstrates how to use the <sup>
tag to display superscript text.
Code Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Sup Tag Example</title>
</head>
<body>
<p>This is an example of a superscript: E = mc2.
<p>In the chemical formula for water, the subscript shows that there are two hydrogen atoms: H2O.</p>
</body>
</html>
Output
This is an example of a superscript: E = mc2.
In the chemical formula for water, the subscript shows that there are two hydrogen atoms: H2O.
The <sup>
tag is a simple yet useful tool for adding superscript text in HTML. It is essential for displaying mathematical notations, footnotes, and scientific formulas.