HTML <sup> class Attribute

The class attribute on a <sup> tag assigns one or more classnames to the supertext element. Classes are used to style elements. Classnames are defined in a stylesheet or in a local <style> element.



A class attribute styling a <sup> element.

42 is 16.

  .red { color: red; }

<p>4<sup class="red">2</sup> is 16.</p>

Using class

The class attribute assigns one or more classnames to the <sup> tag.

Multiple classnames are separated by a space.

Classes (i.e. classnames) are used for styling the sup element.

JavaScript uses classes to access one or more elements by classname.

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


<sup class="classnames">



Value Description
classnames One or more space-separated class names.

More Examples

A class attribute styling a <sup> element.
Clicking the button toggles a classname that boldens the superscript text.

42 is 16.

  .red { color: red; }
  .bold { font-weight:bold; }

<p>4<sup id="mysup" class="red">2</sup> is 16.</p>

<br />
<button onclick="toggle();">Toggle class</button>

  let toggle = () => {
     let element = document.getElementById("mysup");

Code explanation

Two CSS classes are defined in the <style> element.

The class attribute in <sup> assigns one classname.

Repeatedly clicking the button adds and removes the second class, toggling the boldness of the <sup>.

Browser support

Here is when class 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>