<sup>: The Superscript element - HTML: HyperText Markup Language 编辑

The HTML Superscript element (<sup>) 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.

Content categoriesFlow content, phrasing content, palpable content.
Permitted contentPhrasing content.
Tag omissionNone, both the starting and ending tag are mandatory.
Permitted parentsAny element that accepts phrasing content.
Implicit ARIA roleNo corresponding role
Permitted ARIA rolesAny
DOM interfaceHTMLElement

Attributes

This element only includes the global attributes.

Usage notes

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.

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%.

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

  • Displaying exponents, such as "x3." It may be worth considering the use of MathML for these, especially in more complex cases. See Exponents under Examples below.
  • Displaying superior lettering, which is used in some languages when rendering certain abbreviations. For example, in French, the word "mademoiselle" can be abbreviated "Mlle"); this is an acceptable use case. See Superior lettering for examples.
  • Representing ordinal numbers, such as "4th" instead of "fourth." See Ordinal numbers for examples.

Examples

Exponents

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

<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>

The resulting output looks like this:

Superior lettering

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:

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

The resulting output:

Ordinal numbers

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

<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>

The output:

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of '<sub> and <sup>' in that specification.
Living Standard
HTML5
The definition of '<sub> and <sup>;' in that specification.
Recommendation

Browser compatibility

BCD tables only load in the browser

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

See also

  • The <sub> HTML element that produces subscripts. Note that you cannot use them both at the same time and you need to use MathML to produce both a superscript and a subscript next to the chemical symbol of an element, representing its atomic number and its nuclear number.
  • The <msub>, <msup>, and <msubsup> MathML elements.
  • The CSS vertical-align property.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:119 次

字数:8828

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文