Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

<sub>: The Subscript element

BaselineWidely available

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

<p>  Almost every developer's favorite molecule is  C<sub>8</sub>H<sub>10</sub>N<sub>4</sub>O<sub>2</sub>, also known as  "caffeine."</p>
p {  font:    1rem "Fira Sans",    sans-serif;}

Attributes

This element only includes theglobal attributes.

Usage notes

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.

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

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

  • Marking up footnote numbers. SeeFootnote numbers for an example.
  • Marking up the subscript in mathematical variable numbers (although you may also consider using aMathML formula for this). SeeVariable subscripts.
  • Denoting the number of atoms of a given element within a chemical formula (such as every developer's best friend, C8H10N4O2, otherwise known as "caffeine"). SeeChemical formulas.

Examples

Footnote numbers

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

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

Content categoriesFlow content,phrasing content, palpable content.
Permitted contentPhrasing content.
Tag omissionNone, both the starting and ending tag are mandatory.
Permitted parents Any element that acceptsphrasing content.
Implicit ARIA rolesubscript
Permitted ARIA rolesAny
DOM interfaceHTMLElement

Specifications

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

Browser compatibility

See also

  • The<sup> HTML element that produces superscript. Note that you cannot usesup andsub both at the same time: you need to useMathML to produce both a superscript directly above 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 CSSvertical-align property.

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp