How to add superscript text in a paragraph in HTML

What is HTML Superscript Element?

In HTML, <sup> (superscript) element is used to render text in a smaller size and above the baseline in a webpage.

The <sup> tag is often used for thing like exponents.

Example of Creating HTML Superscript Text

Create an HTML <sup> element in a <p> element.

Place the text "2" between the <sup> and </sup> tags after text "a" and "b" as shown in the following example.

The text "2" will be displayed in a smaller size and raised above the baseline text "a" and "b".

Example of HTML Superscript Element


Output of the above example

Example of Superscript Text


a2 + b2 is an example of HTML superscript text.

<sup> tag is used to display superscript text


Let us consider another example of superscript:


Output of the above example

Example of Superscript Text


(a+b)2 = a2+ 2ab + b2 is another example of HTML superscript text.


Live Code Playground

In the following HTML code editor, you can practice the above code by creating more new HTML superscript element. Click on the 'Run Code' button to render the code; the rendered page will be displayed in the following HTML Code Output frame. Practice until you become comfortable and proficient with your code.

HTML logo HTML Online Editor
HTML Code Output