Superscript <sup>text</sup> in HTML

Superscript is a text that appear above the preceding text which means it lies on half a character above the normal base line and the font is smaller. In HTML, superscript is denoted by <sup> tag.

Example of using Superscript in HTML:

OPENGENUS <sup>superscript text</sup>

The output is:

OPENGENUS superscript text

In the above line "superscript text" lies inside the superscript tag.

Table of contents:

  1. Using superscript tag in HTML
  2. Using nested superscript tag in HTML

Let us get started with Superscript <sup>text</sup> in HTML

Using superscript tag in HTML

Superscript tag in HTML uses:

  • <sup> as opening tag
  • </sup> as closing tag

Some use cases of superscript in HTML:

  • To display the exponents.

A common equation in Physics:

<var>E</var>=<var>m</var><var>c</var><sup>2</sup></p>

Output:

E=mc2

  • Represent an ordinal number
2<sup>nd</sup> instead of "second"

Output:

2nd instead of "second"

Superscript tag in HTML is supported on almost all modern browsers. Following is the Browser Compatibility of superscript tag in HTML:

  • Chrome
  • Android
  • Firefox
  • Firefox mobile
  • Internet explorer
  • Edge mobile
  • opera
  • opera mobile
  • safari(webkit)
  • safari mobile

Using nested superscript tag in HTML

Superscript tag can be nested in HTML to any level. Following is the example of nested superscript tag:

opengenus <sup>2<sup>3</sup></sup>

Output:

opengenus 23

The alternative of superscript tag in HTML is the subscript tag which makes text appear before the half character line with smaller font. To learn more about subscript tag, go through this article.

With this article at OpenGenus, you must have the complete idea of Superscript <sup>text</sup> in HTML.