HTML <sup> id Attribute

The id attribute on a <sup> tag assigns an identifier to the superscript text element. The identifier must be unique across the page.



An id attribute on a <sup> tag.

42 is 16.

<p>4<sup id="power2">2</sup> is 16.</p>

Using id

The id attribute assigns an identifier to the <sup> element.

The identifier must be unique across the page.

The id allows programmatic access to the <sup> element.

Tip:  id is a global attribute that can be applied to any HTML element.


<sup id="identifier" />



Value Description
identifier A unique alphanumeric string. The id value must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), colons (:), and periods (.).

More Examples

A <sup> with a unique id attribute.
Clicking the button displays the superscript content.

42 is 16.

<p>4<sup id="mysup">2</sup> is 16.</p>
<br />
<button onclick="show();">Show sup content</button>

  let show = () => {
     let element = document.getElementById("mysup");
     alert("Content = " + element.innerHTML);

Code explanation

The id attribute assigns a unique identifier for the <sup>.

Clicking the button calls JavaScript which locates the <sup> using the id.

Finally, the content of the <sup> element is displayed in an alert box.

Browser support

Here is when id support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like

 Back to <sup>