1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<header><h1><sup>: The Superscript element</h1></header><div class="section-content"><p>The <code><sup></code> <a href="../index">HTML</a> element specifies inline text which is to be displayed as superscript for solely typographical reasons. Superscripts are usually rendered with a raised baseline using smaller text.</p></div>
<h2 id="try_it">Try it</h2>
<div class="section-content"><iframe class="interactive is-tabbed-shorter-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/sup.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe></div>
<h2 id="attributes">Attributes</h2>
<div class="section-content"><p>This element only includes the <a href="../global_attributes">global attributes</a>.</p></div>
<h2 id="usage_notes">Usage notes</h2>
<div class="section-content">
<p>The <code><sup></code> element should only be used for typographical reasons—that is, to change the position of the text to comply with typographical conventions or standards, rather than solely for presentation or appearance purposes.</p> <p>For example, to style the <a href="https://en.wikipedia.org/wiki/Wordmark" target="_blank">wordmark</a> of a business or product which uses a raised baseline should be done using CSS (most likely <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align"><code>vertical-align</code></a>) rather than <code><sup></code>. This would be done using, for example, <code>vertical-align: super</code> or, to shift the baseline up 50%, <code>vertical-align: 50%</code>.</p> <p>Appropriate use cases for <code><sup></code> include (but aren't necessarily limited to):</p> <ul> <li> Displaying exponents, such as "x <sup>3</sup> ." It may be worth considering the use of <a href="https://developer.mozilla.org/en-US/docs/Web/MathML">MathML</a> for these, especially in more complex cases. See <a href="#exponents">Exponents</a> under <a href="#examples">Examples</a> below. </li> <li> Displaying <a href="https://en.wikipedia.org/wiki/Superior_letter" target="_blank">superior lettering</a>, which is used in some languages when rendering certain abbreviations. For example, in French, the word "mademoiselle" can be abbreviated "M <sup>lle</sup> "); this is an acceptable use case. See <a href="#superior_lettering">Superior lettering</a> for examples. </li> <li> Representing ordinal numbers, such as "4 <sup>th</sup> " instead of "fourth." See <a href="#ordinal_numbers">Ordinal numbers</a> for examples. </li> </ul>
</div>
<h2 id="examples">Examples</h2>
<h3 id="exponents">Exponents</h3>
<div class="section-content">
<p>Exponents, or powers of a number, are among the most common uses of superscripted text. For example:</p> <div class="code-example">
<p class="example-header"><span class="language-name">html</span></p>
<pre data-signature="DpXZ/BNHuxtQsdc3kx7MruNXIbi0j2CLfV4RyLBLaYE=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>
One of the most common equations in all of physics is <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>var</span><span class="token punctuation">></span></span>E<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>var</span><span class="token punctuation">></span></span>=<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>var</span><span class="token punctuation">></span></span>m<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>var</span>
<span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>var</span><span class="token punctuation">></span></span>c<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>var</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sup</span><span class="token punctuation">></span></span>2<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>sup</span><span class="token punctuation">></span></span>.
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span>
</pre>
</div> <h4 id="result">Result</h4>
<div class="code-example" id="sect1">
<iframe class="sample-code-frame" title="Exponents sample" id="frame_exponents" width="650" height="80" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/sup/runner.html?id=exponents" loading="lazy"></iframe>
</div>
</div>
<h3 id="superior_lettering">Superior lettering</h3>
<div class="section-content">
<p>Superior lettering is not technically the same thing as superscript. However, it is common to use <code><sup></code> to present superior lettering in HTML. Among the most common uses of superior lettering is the presentation of certain abbreviations in French:</p> <div class="code-example">
<p class="example-header"><span class="language-name">html</span></p>
<pre data-signature="htBaORvyqtGvLwr21mj+XbEeGdAt9HpaTG9h8tV8Y0s=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>Robert a présenté son rapport à M<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sup</span><span class="token punctuation">></span></span>lle<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>sup</span><span class="token punctuation">></span></span> Bernard.<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span>
</pre>
</div> <h4 id="result_2">Result</h4>
<div class="code-example" id="sect2">
<iframe class="sample-code-frame" title="Superior lettering sample" id="frame_superior_lettering" width="650" height="80" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/sup/runner.html?id=superior_lettering" loading="lazy"></iframe>
</div>
</div>
<h3 id="ordinal_numbers">Ordinal numbers</h3>
<div class="section-content">
<p>Ordinal numbers, such as "fourth" in English or "quinto" in Spanish may be abbreviated using numerals and language-specific text rendered in superscript:</p> <div class="code-example">
<p class="example-header"><span class="language-name">html</span></p>
<pre data-signature="DrDkUGGmYQZCO+O83waLiV9u43fGlCWrnGALM2vI7zo=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>
The ordinal number "fifth" can be abbreviated in various languages as follows:
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ul</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>li</span><span class="token punctuation">></span></span>English: 5<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sup</span><span class="token punctuation">></span></span>th<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>sup</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>li</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>li</span><span class="token punctuation">></span></span>French: 5<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sup</span><span class="token punctuation">></span></span>ème<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>sup</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>li</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ul</span><span class="token punctuation">></span></span>
</pre>
</div> <h4 id="result_3">Result</h4>
<div class="code-example" id="sect3">
<iframe class="sample-code-frame" title="Ordinal numbers sample" id="frame_ordinal_numbers" width="650" height="160" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/sup/runner.html?id=ordinal_numbers" loading="lazy"></iframe>
</div>
</div>
<h2 id="technical_summary">Technical summary</h2>
<div class="section-content"><figure class="table-container"><div class="_table"><table class="properties"> <tbody> <tr> <th scope="row"><a href="../content_categories">Content categories</a></th> <td> <a href="../content_categories#flow_content">Flow content</a>, <a href="../content_categories#phrasing_content">phrasing content</a>, palpable content. </td> </tr> <tr> <th scope="row">Permitted content</th> <td>
<a href="../content_categories#phrasing_content">Phrasing content</a>.</td> </tr> <tr> <th scope="row">Tag omission</th> <td>None, both the starting and ending tag are mandatory.</td> </tr> <tr> <th scope="row">Permitted parents</th> <td> Any element that accepts <a href="../content_categories#phrasing_content">phrasing content</a>. </td> </tr> <tr> <th scope="row">Implicit ARIA role</th> <td><code><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/structural_roles#structural_roles_with_html_equivalents">superscript</a></code></td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>Any</td> </tr> <tr> <th scope="row">DOM interface</th> <td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement"><code>HTMLElement</code></a></td> </tr> </tbody> </table></div></figure></div>
<h2 id="specifications">Specifications</h2>
<div class="_table"><table class="standard-table">
<thead><tr><th scope="col">Specification</th></tr></thead>
<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-sub-and-sup-elements">HTML Standard <br><small># the-sub-and-sup-elements</small></a></td></tr></tbody>
</table></div>
<h2 id="browser_compatibility">Browser compatibility</h2>
<div class="_table"><table>
<thead>
<tr id="bct-browser-type">
<th></th>
<th colspan="6">Desktop</th>
<th colspan="6">Mobile</th>
</tr>
<tr id="bct-browsers">
<th></th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
<th>WebView Android</th>
<th>Chrome Android</th>
<th>Firefox for Android</th>
<th>Opera Android</th>
<th>Safari on IOS</th>
<th>Samsung Internet</th>
</tr>
</thead>
<tbody><tr>
<th><code>sup</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">≤4</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">≤3.2</td>
<td class="bc-supports-yes">1.0</td>
</tr></tbody>
</table></div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li>The <a href="sub"><code><sub></code></a> HTML element that produces subscripts. Note that you cannot use <code>sub</code> and <code>sup</code> at the same time: you need to use <a href="https://developer.mozilla.org/en-US/docs/Web/MathML">MathML</a> to produce both a superscript and a subscript next to the chemical symbol of an element, representing its atomic number and its nuclear number.</li> <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub"><code><msub></code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup"><code><msup></code></a>, and <a href="https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msubsup"><code><msubsup></code></a> MathML elements.</li> <li>The CSS <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align"><code>vertical-align</code></a> property.</li> </ul></div><div class="_attribution">
<p class="_attribution-p">
© 2005–2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup</a>
</p>
</div>
|