The font Shorthand and How Browsers Match Fonts
Writing the font shorthand correctly: its value order, the required size and family, line-height after the slash, everything it silently resets, the system font keywords, and the font matching process browsers use to choose a face for each character.
kvi5hnuCode Sprout team member6 min readOn this page
The font shorthand sets the main font properties in one declaration. It's compact and common, especially in resets and component styles, but it has strict ordering rules and resets more than it shows.
Syntax

p { font: 1rem/1.6 Georgia, serif; }
h1 { font: 700 2.25rem/1.1 "Inter", system-ui, sans-serif; }
.note { font: italic 0.875rem system-ui, sans-serif; }
The rules:
font-sizeandfont-familyare required. Tested in Chrome:font: bold Georgiaandfont: 16pxare both invalid.- Style, variant, weight and stretch are optional, in any order, but must come before the size.
- Line height follows the size after a slash:
1rem/1.6. - The family list comes last.
- Only
normalandsmall-capsare allowed for the variant, and only keywords for stretch (condensed, not75%). Tested in Chrome:all-small-caps, or a stretch of75%, makes the declaration invalid.
A subtle trap: anything after the size is part of the family list. Tested in Chrome: font: 1rem bold serif is valid, but it means a family called "bold serif", not bold text.
What font resets
A shorthand sets every property it covers, and anything you leave out goes back to its initial value. For font, that includes properties you can't even write in it. Tested in Chrome, font: italic bold 20px Georgia after other declarations reset:
line-heighttonormalfont-variant-numericand all the otherfont-variant-*properties tonormalfont-feature-settingsandfont-variation-settingstonormalfont-kerningtoauto,font-optical-sizingtoauto,font-size-adjusttonone
It didn't reset font-synthesis or letter-spacing, which aren't part of it.
This causes real bugs:
body { line-height: 1.6; font-variant-numeric: tabular-nums; }
.intro { font: 1.25rem Georgia, serif; } /* line-height is now normal, not inherited 1.6 */
So: write font first, then the longhands that should differ, or use the longhands throughout. In a component, font: inherit is a handy way to make buttons and inputs use the surrounding font (article 102).

The computed values under each paragraph show the reset: the shorthand quietly put font-variant-caps, font-weight and line-height back to their initial values, while letter-spacing, which isn't part of font, was kept.
System font keywords
font also accepts a single keyword that copies the operating system's font for a type of interface element:
| Keyword | Font of |
|---|---|
caption | captioned controls, like buttons |
icon | icon labels |
menu | menus |
message-box | dialog boxes |
small-caption | small controls |
status-bar | window status bars |
.toolbar { font: menu; }
These set all the font properties at once, and the values depend on the platform. For a native look, font-family: system-ui (article 82) is more common today.
How browsers match fonts
For every character, the browser runs a font matching process. Knowing it explains most "why is this font used?" questions:
- Family. Take the first family in
font-family. If it's a web font family, the candidates are its@font-facerules; if it's an installed font, the faces of that family on the system. - Width. From the candidates, keep the faces closest to the requested
font-stretch: narrower ones first when the request is below 100%, wider ones first above. - Style. Keep the faces closest to the requested
font-style: foritalic, italic faces first, then oblique, then upright. - Weight. Choose the closest weight by the rule in article 83: for requests above 500, heavier first; below 400, lighter first; between 400 and 500, up to 500, then lighter, then heavier.
- Character coverage. If the chosen face has
unicode-rangethat excludes the character, or lacks a glyph for it, try the next face of the family that covers it, and then the next family in the list. - Generic and system fallback. If no listed family has the character, use the generic family, and finally any installed font with that glyph.
- Synthesis. If the selected face is lighter than requested or not italic, the browser may synthesize bold or oblique, unless
font-synthesisforbids it (article 85).
Because width and style are matched before weight, a family with only a bold italic face uses it for italic text at any weight, and fakes the rest.
If a web font for step 1 hasn't loaded yet, font-display decides whether text waits or uses the next family temporarily (article 84).
body { font: 0.8rem system-ui, sans-serif; margin: 1rem; }
.base { line-height: 2.2; font-variant-numeric: tabular-nums; font-family: system-ui, sans-serif; }
.base p { margin: 0 0 0.4rem; padding: 0 0.4rem; background: #f4efe6; font-size: 1.1rem; }
.a { font-size: 1.1rem; font-weight: 700; } /* only these two change */
.b { font: 700 1.1rem system-ui, sans-serif; } /* resets line-height and numerals too */
.note { color: #555; }
The second line loses the inherited line-height and tabular numerals, because the shorthand reset them to normal.
What's current
- The
fontshorthand works the same in all browsers. - Newer font properties (
font-optical-sizing,font-variation-settings,font-variant-emoji) are reset byfonttoo, though they can't be set in it.
Common questions
Why is my line-height lost?
A font shorthand later in the cascade reset it to normal. Include it after the slash, or set line-height after the shorthand.
Why is font: bold 1rem ignored?
The family is required. Add one, even if it's only a generic like sans-serif.
Why isn't my text bold with font: 1rem bold Arial?
The weight must come before the size. After the size, "bold Arial" is read as a family name.
Which font does the browser use if my chosen weight doesn't exist? The nearest weight in the same family by the matching rules, after width and style; if none is close enough, it may synthesize.
Summary
font: [style variant weight stretch] size[/line-height] familywith size and family required, and the family last.- Only
normal/small-capsvariants and keyword stretches are allowed in it. - It resets
line-height, allfont-variant-*, feature and variation settings, kerning, optical sizing andfont-size-adjust. - Write
fontfirst and longhands after, or use longhands only. - Browsers match family, then width, style and weight, then character coverage, then fallback and synthesis.
Practice questions
Rewrite these longhands as one font declaration.
font-style: italic;
font-weight: 600;
font-size: 1.125rem;
line-height: 1.4;
font-family: Georgia, serif;
Answer
font: italic 600 1.125rem/1.4 Georgia, serif;
Which of these declarations are invalid?
a { font: 16px; }
b { font: bold 16px Arial; }
c { font: 16px/1.5 bold Arial; }
d { font: condensed 16px Arial; }
Answer
Only a, which has no family. c is valid but means a family called "bold Arial", with normal weight. b and d are fine.
A component sets font: 1rem system-ui after a parent's font-variant-numeric: tabular-nums. Are its numbers tabular?
Answer
No. The shorthand resets font-variant-numeric to normal on the component. Set font-variant-numeric: tabular-nums after the shorthand, or inherit it explicitly.
A family has faces for regular (400 normal) and bold italic (700 italic) only. What face is used for font-style: italic; font-weight: 400?
Answer
The bold italic face. Style is matched before weight, so the only italic face wins, even though its weight is further from 400.
Previous: Variable Fonts: Axes, font-variation-settings and Optical Sizing
Next: Text Alignment, Indentation, Spacing and text-transform

More in CSS Course
Quiz: CSS Delicate Details
Twenty-five questions on the edge cases that surprise experienced developers: invalid custom properties, shorthands that reset values, layer order with !important, containing blocks, margin collapsing, specificity of :is() and :where(), intrinsic minimum sizes, and more, each checked in Chrome.
Quiz: CSS Interview Questions
Thirty front-end interview questions: cascade, specificity and layers, box model and margin collapsing, stacking contexts, positioning, flexbox and grid, responsive design, custom properties, performance, accessibility, modern selectors and architecture.
Quiz: CSS Course Final Exam
Thirty questions across the whole CSS course: syntax and error handling, selectors, the cascade and layers, values and units, color, the box model, backgrounds, positioning, flexbox, grid, responsive design, typography, generated content, effects, transforms, motion and architecture.
Quiz: CSS Architecture, Tooling and Debugging (CSS Part 17)
Twenty questions on modular CSS and BEM, layering a stylesheet, design tokens and theming, pattern libraries and safe refactoring, preprocessors and build tools, the at-rules reference, and debugging common CSS problems.
Discussion
Sign in to ask a question or share what you learned.