<sup>:上标元素

<sup> HTML 元素指定仅出于印刷原因而显示为上标的内联文本。上标通常使用较小的文本以凸起的基线呈现。

¥The <sup> HTML 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.

Try it

属性

¥Attributes

该元素仅包含 全局属性

¥This element only includes the global attributes.

使用说明

¥Usage notes

<sup> 元素只能用于印刷原因,即更改文本的位置以符合印刷惯例或标准,而不能仅用于演示或外观目的。

¥The <sup> 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.

例如,要设置使用升高基线的业务或产品的 wordmark 样式,应使用 CSS(最有可能是 vertical-align)而不是 <sup> 来完成。例如,可以使用 vertical-align: super 或将基线上移 50% 的 vertical-align: 50% 来完成。

¥For example, to style the wordmark of a business or product which uses a raised baseline should be done using CSS (most likely vertical-align) rather than <sup>. This would be done using, for example, vertical-align: super or, to shift the baseline up 50%, vertical-align: 50%.

<sup> 的适当用例包括(但不一定限于):

¥Appropriate use cases for <sup> include (but aren't necessarily limited to):

  • 显示指数,例如 "x3"。对于这些情况,尤其是在更复杂的情况下,可能值得考虑使用 MathML。请参阅下面 示例 下的 指数
  • 显示 优质刻字,在某些语言中呈现某些缩写时会使用该值。例如,在法语中,单词 "mademoiselle" 可以缩写为 "Mlle";这是一个可以接受的用例。示例请参见 优质刻字
  • 表示序数,例如 "第四个th" 而不是 "第四。" 示例请参见 序数词

示例

¥Examples

指数

¥Exponents

指数或数字的幂是上标文本最常见的用法之一。例如:

¥Exponents, or powers of a number, are among the most common uses of superscripted text. For example:

html
<p>
  One of the most common equations in all of physics is <var>E</var>=<var>m</var
  ><var>c</var><sup>2</sup>.
</p>

结果

¥Result

优质刻字

¥Superior lettering

从技术上讲,高级字体与上标不同。然而,通常使用 <sup> 在 HTML 中呈现高级字体。高级字体最常见的用途之一是用法语表示某些缩写:

¥Superior lettering is not technically the same thing as superscript. However, it is common to use <sup> to present superior lettering in HTML. Among the most common uses of superior lettering is the presentation of certain abbreviations in French:

html
<p>Robert a présenté son rapport à M<sup>lle</sup> Bernard.</p>

结果

¥Result

序数词

¥Ordinal numbers

序数词,例如英语中的 "fourth" 或西班牙语中的 "quinto",可以使用数字和上标呈现的特定于语言的文本进行缩写:

¥Ordinal numbers, such as "fourth" in English or "quinto" in Spanish may be abbreviated using numerals and language-specific text rendered in superscript:

html
<p>
  The ordinal number "fifth" can be abbreviated in various languages as follows:
</p>
<ul>
  <li>English: 5<sup>th</sup></li>
  <li>French: 5<sup>ème</sup></li>
</ul>

结果

¥Result

技术总结

¥Technical summary

内容类别 流量内容措辞内容,可触及的内容。
允许的内容 措辞内容.
标签遗漏 无,开始和结束标记都是强制性的。
允许的父级 任何接受 措辞内容 的元素。
隐式 ARIA 角色 superscript
允许的 ARIA 角色 任何
DOM 接口 HTMLElement

规范

Specification
HTML Standard
# the-sub-and-sup-elements

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看

¥See also

  • 生成下标的 <sub> HTML 元素。请注意,你不能同时使用 subsup:你需要使用 MathML 在元素的化学符号旁边生成上标和下标,分别代表其原子序数和核序数。
  • <msub><msup><msubsup> MathML 元素。
  • CSS vertical-align 属性。