TocTable of Contents
Css baseline 2026
Overview of 2026 baseline css features
Math font family
The math generic font family keyword tells the browser to use its preferred font for rendering mathematical expressions. It joins ui-sans-serif, ui-serif, and ui-monospace as a system-native font choice, requiring no custom font files.
| |
The browser selects an appropriate math font from the system — such as Latin Modern Math or STIX Two Math — that includes the specialist glyphs, symbols, and spacing rules needed for mathematical notation.
Mathematical typesetting has unique requirements that regular text fonts do not meet:
- Operator symbols (
∑,∫,√) at multiple sizes - Stretchy delimiters that scale with their content
- Precise spacing rules between operands
- Specialised variants (bold, italic, script, fraktur) for variables and operators
Using a math-aware font ensures these are rendered correctly by default.
font-family: math is most relevant alongside MathML, the HTML standard for mathematical markup:
| |
| |
Including named math fonts as fallbacks ensures consistent rendering in browsers or systems where the generic math keyword is not yet supported.
:active-view-transition
The :active-view-transition pseudo-class matches the root element when a view transition is currently in progress. It gives you a hook to apply styles globally for the duration of any view transition, without having to target the specific pseudo-elements involved in the animation itself.
A common use case is disabling pointer events or suppressing certain UI elements while the transition plays, preventing user interaction from interfering with the animation.
| |
:active-view-transition is a straightforward way to coordinate global state with the view transition lifecycle, complementing the more granular control offered by ::view-transition-old and ::view-transition-new.
:open
The :open pseudo-class matches interactive elements that are currently in an open or expanded state. It provides a unified selector for elements whose open state is toggled by the browser, covering <details>, <dialog>, <select>, <input> types with pickers, and elements with the popover attribute.
Previously, different elements required different selectors to target their open state: details[open] for details elements, no standard selector for open dialogs, and so on. :open unifies these under a single pseudo-class.
| |
Using :open makes styles more readable and consistent, and reduces the need to remember which attribute or state mechanism each element type uses for its open condition.
baseline-shift
The baseline-shift property moves an inline element up or down relative to the dominant baseline of its parent. It is the CSS equivalent of the SVG baseline-shift presentation attribute, and is primarily used in SVG text to produce superscript and subscript effects without changing font size.
| |
The super and sub keywords shift the element to a typical superscript or subscript position relative to the parent’s baseline. Length and percentage values provide precise control over the shift amount — positive values move the element up, negative values move it down.
In HTML, vertical-align with super and sub values, or with explicit length offsets, serves the same purpose for inline elements. baseline-shift is specifically relevant when authoring SVG text or working in contexts where SVG’s typographic model applies. The two properties address the same visual intent through different specifications: vertical-align for HTML inline layout, baseline-shift for SVG text layout.
Container style queries
Container style queries let you apply styles based on the computed value of a CSS custom property on a container element — not just its size. This enables state-driven styling through CSS alone.
| |
When the container has --variant: featured, the card gets special styling.
Style queries can be used for theming
| |
Quite powerful, because previously, changing styles based on a parent’s state required JavaScript adding classes. Style queries allow this with pure CSS custom properties.
Container style queries can be combined with size queries
| |
contrast-color()
The contrast-color() function returns the color from a provided list that has the highest contrast against a given background color. Its initial, simplified form takes a single background color and returns whichever of white or black contrasts best with it.
| |
This eliminates a very common problem in dynamic theming: ensuring text remains readable over a background whose color is set at runtime via a custom property or user preference. Previously this required JavaScript to calculate luminance and decide between dark and light text. contrast-color() does this in CSS, reacting automatically to changes in the background value.
The longer-term specification extends the function to accept an arbitrary list of candidate colors, returning whichever achieves the best contrast ratio, along with optional target contrast level constraints. The simpler contrast-color(color) form returning black or white is the initial implementation available in browsers.
field-sizing
The field-sizing property controls whether form fields size themselves based on their content or maintain a fixed size. The default behaviour for text inputs and textareas is field-sizing: fixed — they have a defined size and do not grow or shrink as the user types. Setting field-sizing: content changes this so the field adjusts its size to fit its current value.
| |
With field-sizing: content, a textarea grows as the user types more content, up to any max-height you set, and a text input expands horizontally to fit its value. Previously, this behaviour required JavaScript event listeners on the input to manually adjust dimensions.
Combining field-sizing: content with min-* and max-* properties gives you full control over the range of sizes the field can take, keeping the experience predictable while still being responsive to the user’s content.
Rcap unit
The rcap unit is the root-relative version of cap. Where cap measures the cap height of the current element’s font, rcap measures the cap height of the root element’s font — typically the <html> element — regardless of the font applied to the element being styled.
This mirrors the relationship between em and rem: rcap gives you a stable, consistent reference point that does not change as you nest elements with different font-size or font-family values.
| |
rcap is especially useful in design systems where you want decorative elements or spacing tokens to remain anchored to a single typographic baseline across an entire page, independent of local font overrides.
rch
The rch unit is the root-relative counterpart to ch. The ch unit represents the width of the “0” (zero) character in the current element’s font, making it useful for sizing text inputs or containers to a certain number of characters. rch does the same, but always references the root element’s font rather than the element’s own font.
This makes rch a predictable, globally stable unit for character-based measurements. When you have components that override the font family or size locally, using rch keeps any character-width-based sizing anchored to the root, avoiding unexpected layout shifts.
| |
Like all root-relative units, rch is most valuable in systems that set a clear typographic baseline on the root element and want consistent measurements throughout the document.
rex
The rex unit is the root-relative version of ex. The ex unit represents the x-height of the current font — roughly the height of a lowercase “x” — and is commonly used for fine typographic adjustments. rex provides the same measurement, but always taken from the root element’s font.
Because x-height varies widely between typefaces, ex can produce very different results depending on what font is active on a given element. rex eliminates that variability by fixing the reference to the root font, giving you a stable unit for spacing and sizing decisions that need to feel optically connected to the base typography without being affected by local font changes.
| |
rex fits naturally alongside rem and rcap as part of a family of root-anchored typographic units, each targeting a different characteristic of the root font.
Ric unit
The ric unit is the root-relative version of ic. The ic unit is similar to ch but instead of using the “0” character, it uses the “水” (CJK water ideograph) as its reference glyph, making it well-suited for sizing in CJK (Chinese, Japanese, Korean) typography where full-width characters are the norm.
ric applies the same concept but always references the root element’s font, providing a consistent baseline for CJK-aware sizing regardless of local font overrides on individual elements.
| |
For multilingual layouts where CJK and Latin text coexist, ric offers a stable typographic unit that stays anchored to a single reference point, helping keep proportions consistent across sections that may use different typefaces.
text-indent: each-line
The each-line keyword extends text-indent so that indentation applies not just to the first line of a block, but to every line that begins after a forced line break (like <br> or a newline in white-space: pre).
| |
Soft-wrapped lines (that wrap due to limited width) are NOT indented — only forced breaks.
| |
hanging reverses the direction (outdents the first line instead), while each-line applies the rule after forced breaks too.
Can be used for:
- Poetry where each verse line should be indented
- Script or dialogue formatting with forced line breaks
- Legal documents with structured line-by-line indentation
text-indent: hanging
The hanging keyword inverts the direction of text-indent: instead of indenting the first line, it indents every line except the first — a hanging indent (also called an outdent).
| |
A negative value with hanging creates the classic bibliography format: the first line starts at the left margin, and wrapped lines are indented.
Without hanging: indent is positive → first line moves right.
With hanging: the meaning flips → first line stays, subsequent lines move right.
Where to use:
- Bibliographies and works-cited lists
- Glossaries and definition lists
- Dictionary entries
- Numbered lists with long first items
| |
Combining with each-line applies the hanging indent after every forced line break as well.