<sub>: The SUB Element

Last updated: 2026-10-13

<sub>The SUB Element

Defines subscript text shown below the baseline, used in chemical formulas (e.g. H₂O) and math notation.

CategoryFormatting
Content ModelPhrasing content
Allowed ParentsAny element that accepts phrasing content
Content TagYes — requires closing </sub> tag
StatusStandard

📝 Syntax

<sub>subscript</sub>

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
<sub> ✓ v1 ✓ v12 ✓ v1 ✓ v1 ✓ v1
Supported in all major browsers
Tip: Subscript changes line height; use sparingly in long text to avoid uneven spacing.

❓ FAQ

QWhat are typical use cases for sub?
AChemical formulas (the 2 in H₂O written as <sub>2</sub>), subscripts in math variables, and footnote numbering. It displays text below the baseline in a smaller size, with the semantics of a subscript rather than a visual offset.
QHow does sub differ from CSS vertical-align?
A<sub> carries subscript semantics with the browser default style vertical-align: sub plus a smaller font; CSS can mimic the look but without semantics. When the content truly is a subscript (chemistry, math notation) use <sub>; for pure typographic tweaks use CSS.
QDoes sub affect line height?
AIt can. A lowered subscript may increase the line box height and make paragraph spacing uneven. Fix it by setting line-height: 0 on <sub>, or adjusting the vertical-align offset so it displays without expanding the line.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏