The CSS font-family property sets which typeface an element uses, and it takes a comma-separated list called a font stack. The browser tries each name in order and uses the first one that is available, so a good stack ends with a generic family such as sans-serif. For example: font-family: "Inter", Arial, sans-serif;.
Understanding css font-family means knowing how fallback works, when to quote names, which generic families exist, and how to build stacks that look good before a custom font has loaded. This guide covers all four, plus system font stacks.
The value is a list of family names. The browser checks the first name; if that font is not installed or loaded, it moves to the next, and so on.
Fallback also works per character. If the first font lacks a glyph, such as an emoji or a Hindi letter, the browser can pick that glyph from a later font in the list or from a system fallback.
"Times New Roman" or "Source Sans 3".Arial or Georgia do not need quotes, but quoting them is allowed.serif, sans-serif, monospace). Quoted, they are treated as a font literally named "serif".Every stack should end with a generic family, which guarantees something reasonable is chosen on any device.
| Generic family | Typical look | Common use |
|---|---|---|
serif | Strokes with small finishing marks | Long-form reading, editorial text |
sans-serif | Clean strokes without finishing marks | UI, body text on screens |
monospace | Every character the same width | Code |
cursive | Handwriting style | Rare, decorative use |
fantasy | Decorative display style | Rare, avoid for body text |
system-ui | The operating system's UI font | Native-feeling interfaces |
ui-serif, ui-sans-serif, ui-monospace, ui-rounded | System fonts by style | App-like styling |
Which actual font a generic name maps to depends on the user's device and settings.
A good stack has three parts: the font you want, one or two close alternatives available on common systems, and a generic family.
Storing stacks in CSS custom properties keeps them consistent across the site and easy to change in one place.
A system font stack uses fonts already installed on the device, so there is nothing to download and text appears instantly.
The result feels native on each platform, but looks different between macOS, Windows and Android.
If you load a custom font with @font-face, put it first in the stack and keep a metric-similar fallback after it. A fallback with very different widths makes the layout jump when the web font arrives, which hurts the Cumulative Layout Shift metric.
Loading custom fonts with @font-face and font-display is covered in a related article. For now, remember that the name in font-family must match the family name you declared there exactly.
font-family can also be set in the font shorthand, where it must be the last value and a size is required before it:
The shorthand resets every other font property it covers, so use it with care when other rules set weight or style.
Having a name in the stack does not mean it renders. Open the browser developer tools, select an element and look at the Computed or Fonts panel, which shows the rendered font. This is the quickest way to find out whether your first choice loaded or a fallback is being used.
The browser falls back to its default font, usually a serif. This is why every stack should end with a generic family.
Only for names with spaces, digits at the start or special characters. Generic keywords like sans-serif must never be quoted.
Yes. Wrap the word in a <span> with a class and set font-family on that class. Keep the number of different families small for performance and a consistent look.
If the font is not installed on that computer and you did not load it as a web font, the browser uses the next entry in the stack. Use web fonts or a system stack for consistent results.
font-family is a prioritized list. Name your preferred font first, add close fallbacks, and end with a generic family. Quote names with spaces, never quote generic keywords, and keep stacks in custom properties. Use a system stack when speed and native feel matter more than a branded typeface.