HTML上标和下标

上标

HTML <sup> 标签用于创建上标文本。<sup> 标签内的文本会比正常行高半个字符,并且字体更小。例如,

<p> This is a <sup>Superscript</sup> text.</p>

浏览器输出

HTML Superscript text

上标的用法

上标文本通常用于指数、度量单位和序数。例如,

1. 指数中的上标

<p> a<sup>2</sup> + b<sup>2</sup> = c<sup>2<sup></p>

浏览器输出

Exponents written in superscript

2. 度量单位中的上标

<p>The area of this park is 200m<sup>2</sup>.</p>

浏览器输出

Units of measurement written in superscript

3. 序数中的上标

<p>Ram scored 1<sup>st</sup> position in the 100m race.</p>

浏览器输出

Ordinal position written in superscript

下标

HTML <sub> 标签用于创建下标文本。<sub> 标签内的文本会比正常行低半个字符,并且字体更小。例如,

<p> This is a <sub>Subscript</sub> text.</p>

浏览器输出

HTML Subscript text

下标的用法

上标文本通常用于数学和化学公式。例如,

1. 数学公式中的用法

<p> <var>x<sub>1</sub></var> … <var>x<sub>n</sub></var></p>

浏览器输出

Mathematic formula written in subscript

2. 化学公式中的用法

<p> H<sub>2</sub>SO<sub>4</sub> is chemical formula for sulphuric acid.</p>

浏览器输出

Chemical formula written in subscript

我们的高级学习平台,凭借十多年的经验和数千条反馈创建。

以前所未有的方式学习和提高您的编程技能。

试用 Programiz PRO
  • 交互式课程
  • 证书
  • AI 帮助
  • 2000+ 挑战