0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Represents subscript text for chemical formulas, mathematical notation, and variable subscripts. Rendered smaller and below the baseline in any font.
Description
The <sub> element displays inline text as subscript. VB always renders it at 0.75em, shifted below the baseline with a relative offset and line-height: 0, so the subscript does not push the line taller. This works in every font. Fonts with designed OpenType subscript glyphs can opt in to them with data-variant="opentype".
When to Use
Chemical formulas: H2O, CO2
Mathematical subscripts: Variable indices like an
When NOT to Use
For purely visual positioning — use CSS vertical-align: sub
For complex math — consider MathML
For footnote markers — those are superscripts; use <sup>
sub,sup {font-size: 0.75em;line-height: 0; /* keeps the line box from growing */position: relative;vertical-align: baseline;}sub { inset-block-end: -0.25em; }sup { inset-block-end: 0.5em; }/* Opt-in: the font's own OpenType subs/sups glyphs */:is(sub, sup)[data-variant~="opentype"] {font-size: inherit;position: static;inset-block-end: auto;}sub[data-variant~="opentype"] { font-variant-position: sub; }sup[data-variant~="opentype"] { font-variant-position: super; }
The size and offset always apply. An earlier version reset them inside @supports (font-variant-position: sub), but that check only shows the browser understands the property, not that the font has subscript glyphs. In most fonts, subscripts then rendered at full size on the baseline.
OpenType glyphs (opt-in)
Some fonts include designed subscript glyphs. Add data-variant="opentype" to use them with font-variant-position: sub. VB then removes its own size and offset, because the glyphs are already small and positioned.
OpenType subscript
1
<p>H<subdata-variant="opentype">2</sub>O</p>
Only use this when you know the current font has the glyphs. Browsers do not synthesise them, and @supports cannot detect them. In a font without them (Georgia, Verdana, Courier New and most display fonts), opted-in text renders at full size on the baseline. That is why the default reduced size and offset are always applied.
Accessibility
Screen readers may not announce subscript formatting
For chemical formulas, the subscript is understood from context
For complex math, consider MathML or aria-label on the container
Related
Typography guide — how subscript and superscript are sized and positioned