Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

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…

Read the release notes

math

Native MathML rendering with a self-hosted math font, display and inline modes, numbered and captioned equations.

Overview

The <math> element renders MathML notation natively in the browser. MathML Core is supported in all major engines: Chrome 109+, Firefox, and Safari. No JavaScript or external libraries required.

Vanilla Breeze adds a self-hosted math font, display-math layout, numbered equations via CSS counters and captioned figures. Everything else (baseline alignment, operator spacing, script sizes) is left to MathML Core and the font's OpenType MATH table. Math inherits the surrounding text colour, so it follows light and dark mode, and mathcolor works on individual tokens.

Inline Math

Inline math flows within paragraph text and sits on the text baseline (MathML Core's default; VB does not override it). Tall inline expressions open up the line box rather than overlapping neighbouring lines.

Display Math

Use display="block" for centered, standalone equations with vertical margins.

Numbered Equations

Wrap math[display="block"] in a figure.equation (or p.equation) for auto-incrementing equation numbers. Numbering uses CSS counters, so it works without JavaScript and respects DOM order. The count restarts in each <article> and runs across its sections and asides. Container queries scope counters, so an article that contains an equation, and its sections, are not query containers (add data-container to opt a box back in; it then numbers on its own). Outside an article, each container (<main>, <section>) numbers separately.

Common Patterns

Fractions

Radicals

Summation

Matrices

Captioned Equations

Use figure.math to wrap an equation with a <figcaption>.

Attributes

Attribute Values Description
display "block" Renders as centered block equation. Without this attribute, math renders inline.
mathcolor Any CSS colour On token elements (mi, mn, mo…). VB sets no token colours, so the hint is honoured.

This element also supports global attributes.

VB Classes

Class Description
equation On a <figure> or <p> wrapping a math[display="block"]: adds an auto-incrementing equation number via CSS counters (MathML elements cannot take ::after).
math On a <figure>: centres the equation and styles its <figcaption>.

Colour

Math inherits color from its context and VB applies no per-token colours, so the mathcolor attribute works:

Font Loading

MathML rendering quality depends on a font with an OpenType MATH table. The core stylesheet declares a self-hosted Latin Modern Math face (woff2, font-display: swap, GUST Font License shipped alongside), falling back to STIX Two Math, Cambria Math and the generic math family.

Nothing extra is needed for plain <math>: the browser fetches {cdn}/fonts/latinmodern-math.woff2 only when a page actually renders math, and a locally installed Latin Modern Math is used first. Pages without math never download it.

If you load only the web-components stylesheet, link the standalone face from the same cdn/ folder you serve VB from (on this site, /cdn/fonts/math-fonts.css):

The data-math attribute injects that stylesheet automatically when it renders math.

Accessibility

  • Browsers expose native MathML to the accessibility tree. VoiceOver (Safari) reads it directly; NVDA reads and navigates it with the MathCAT add-on (MathPlayer is no longer maintained); JAWS has its own math support. Coverage and verbosity differ between them
  • No ARIA hacks required
  • Use <semantics> and <annotation> to carry the source (LaTeX, ASCIIMath) alongside the presentation markup
  • Equation numbers are generated content and are not reliably announced; refer to equations in prose too
  • Colour set with mathcolor is not announced — don't rely on it alone

Related

  • data-math — enhance <code> elements with precompiled MathML
  • <var> — for variable names in prose text (when you don't need full math notation)
  • <sup> / <sub> — for simple exponents and subscripts in running text without MathML
  • <svg> — scalable vector graphics
  • <code> — inline code
↑