<sub>:下标元素

<sub> HTML 元素指定内联文本,仅出于印刷原因应将其显示为下标。下标通常使用较小的文本以较低的基线呈现。

¥The <sub> HTML element specifies inline text which should be displayed as subscript for solely typographical reasons. Subscripts are typically rendered with a lowered baseline using smaller text.

Try it

属性

¥Attributes

该元素仅包含 全局属性

¥This element only includes the global attributes.

使用说明

¥Usage notes

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

¥The <sub> element should be used only 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.

例如,使用 <sub> 来设置在 wordmark 中使用更改基线的公司名称的样式是不合适的;相反,应该使用 CSS。例如,你可以将 vertical-align 属性与 vertical-align: sub 之类的声明一起使用,或者为了更精确地控制基线偏移,使用 vertical-align: -25%

¥For example, using <sub> to style the name of a company which uses altered baselines in their wordmark would not be appropriate; instead, CSS should be used. For example, you could use the vertical-align property with a declaration like vertical-align: sub or, to more precisely control the baseline shift, vertical-align: -25%.

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

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

  • 标记脚注编号。请参阅 脚注编号 的示例。
  • 用数学变量数字标记下标(尽管你也可以考虑使用 MathML 公式)。参见 变量下标
  • 表示化学式中给定元素的原子数(例如每个开发者最好的朋友,C 8 H 10 N 4 O 2 ,也称为 "caffeine")。参见 化学式

示例

¥Examples

脚注编号

¥Footnote numbers

传统的脚注使用下标表示的数字来表示。这是 <sub> 的常见用例:

¥Traditional footnotes are denoted using numbers which are rendered in subscript. This is a common use case for <sub>:

html
<p>
  According to the computations by Nakamura, Johnson, and Mason<sub>1</sub> this
  will result in the complete annihilation of both particles.
</p>

结果

¥Result

变量下标

¥Variable subscripts

在数学中,与同一概念(例如沿同一轴的距离)相关的变量族使用相同的变量名称并带有下标来表示。例如:

¥In mathematics, families of variables related to the same concept (such as distances along the same axis) are represented using the same variable name with a subscript following. For example:

html
<p>
  The horizontal coordinates' positions along the X-axis are represented as
  <var>x<sub>1</sub></var><var>x<sub>n</sub></var>.
</p>

结果

¥Result

化学式

¥Chemical formulas

当书写化学式时,例如 H20,所描述分子内给定元素的原子数用下标数字表示;对于水,下标 "2" 表示分子中有两个氢原子。

¥When writing a chemical formula, such as H20, the number of atoms of a given element within the described molecule is represented using a subscripted number; in the case of water, the subscripted "2" indicates that there are two atoms of hydrogen in the molecule.

另一个例子:

¥Another example:

html
<p>
  Almost every developer's favorite molecule is
  C<sub>8</sub>H<sub>10</sub>N<sub>4</sub>O<sub>2</sub>, which is commonly known
  as "caffeine."
</p>

结果

¥Result

技术总结

¥Technical summary

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

规范

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

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看

¥See also

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