CKTIS / CSS
font — font shorthand property
The font property sets several font parameters in one declaration. Its ordinary form requires a size and family; omitted components are reset rather than preserving earlier settings.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
font: [ [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'># ] | <system-font-family-name>;font combines settings for font-style, font-variant, font-weight, font-width (legacy name: font-stretch), font-size, line-height, and font-family. Its ordinary form requires font-size followed by a font-family list. Optional style, variant, weight, and width settings appear before the size, in any order. line-height follows the size after /; separate families with commas.
Not every longhand value fits the shorthand. The variant is limited to normal or small-caps, and width to CSS Fonts Level 3 keywords such as condensed; percentage widths are not part of this syntax. Alternatively, use one system keyword: caption, icon, menu, message-box, small-caption, or status-bar. It selects a platform-dependent set of font parameters, not just a font family.
Watch for resets: the shorthand assigns initial values to omitted components. It also resets properties that it cannot directly set, such as font-variant-numeric, font-kerning, and font-feature-settings. However, it does not reset everything prefixed with font-: font-palette and the font-synthesis components remain independent. Place detailed overrides after the shorthand, taking the cascade into account.
In the example, the later font: 16px/24px sans-serif replaces font-weight: 700 with its initial value and resets font-variant-numeric. The expected readout is 16px, 24px, 400, normal, each on its own line. Glyph appearance depends on the available font; the test checks computed values, not identical rendering.
Examples
<!doctype html>
<meta charset="utf-8">
<title>font shorthand</title>
<style>
#sample {
font-weight: 700;
font-variant-numeric: tabular-nums;
font: 16px/24px sans-serif;
}
</style>
<p id="sample">Font shorthand: 0123456789</p>
<pre id="result"></pre>
<script>
const style = getComputedStyle(document.getElementById('sample'));
document.getElementById('result').textContent = [
style.fontSize,
style.lineHeight,
style.fontWeight,
style.fontVariantNumeric
].join('\n');
</script>Result
16px 24px 400 normal
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.