CSS font-family Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The font-family property sets a prioritized list of typefaces for text. The browser tries each name in order and uses the first font that is available (installed or loaded via @font-face).

Always end the list with a generic family such as sans-serif or serif. The property is inherited. Pair it with font-size, font-weight, and the font shorthand when you need more than a typeface.

Standard-track.

Not deprecated. Core families are Baseline widely available. Newer generics such as math and ui-* have uneven support — keep a classic fallback in the stack.

CSS Syntax

syntax.css
font-family: <family-name> | <generic-family> [ , <family-name> | <generic-family> ]* | initial | inherit;

Comma-separated stack. Preferred fonts first; a generic last. Example: "Georgia", serif.

Property Values

ValueDescriptionTry it
<family-name>A named font. Quote names with spaces (e.g. "Times New Roman")Try it
serifGeneric with finishing strokes (e.g. Times-like)Try it
sans-serifGeneric with plain stroke endings (e.g. Arial-like)Try it
monospaceFixed-width glyphs (code and data)Try it
cursiveHandwriting-like genericTry it
fantasyDecorative generic (exact face varies by OS)Try it
system-uiPlatform UI font. Prefer for controls, not long articlesTry it
initialResets to the user-agent default familyTry it
inheritTakes the parent font-family (default behavior is already inherited)Try it

How to Use font-family

Build a short stack: preferred fonts, then a safe generic.

  1. List your preferred named fonts first (quote names with spaces).
  2. Add close alternatives that are common on user systems.
  3. End with a generic: sans-serif, serif, or monospace.
  4. Load custom fonts with @font-face when needed, still keeping a fallback stack.
PieceRequired?Role
Named fontsOptionalExact typefaces you prefer
Generic familyStrongly recommendedLast-resort style match
QuotesWhen neededSpaces / special characters in names

Live Preview

Change only font-family. Size and weight stay fixed so you can compare typefaces.

The exact face depends on fonts installed on this device.

Typeface

The quick brown fox jumps over the lazy dog.

font-family: Georgia, serif

CSS Examples

Each snippet focuses on font-family. Use Try It Yourself for a live editor.

Example 1 — Named Stack with Fallback

Prefer Georgia; fall back to any serif if it is missing.

CSS
<style>
  p {
    font-family: Georgia, serif;
  }
</style>

<p>Readable serif text</p>
Try It Yourself

How It Works

  1. Prefer a named font. Georgia is tried first.
  2. Add a generic. serif is the safety net if Georgia is not installed.
  3. Order matters. Left to right means highest to lowest priority.
  4. Do not quote generics. serif is a keyword, not a font file name.

Example 2 — Common Sans-Serif Stack

A typical UI stack with a generic ending.

CSS
<style>
  p {
    font-family: Arial, Helvetica, sans-serif;
  }
</style>

<p>Clean sans-serif text</p>
Try It Yourself

How It Works

  1. List common faces. Arial, then Helvetica, cover most systems.
  2. Finish with sans-serif. Style stays consistent if both names fail.
  3. Single-word names. Arial and Helvetica usually need no quotes.
  4. Good for UI. Sans stacks read clearly at small sizes.

Example 3 — Monospace for Code

Fixed-width letters for snippets and data.

CSS
<style>
  code {
    font-family: "Courier New", Courier, monospace;
  }
</style>

<code>const x = 42;</code>
Try It Yourself

How It Works

  1. Quote multi-word names. "Courier New" needs quotes because of the space.
  2. Add a close twin. Courier is a common alternate.
  3. End with monospace. Every glyph stays equal width.
  4. Size tip. Bare monospace alone can use a smaller browser default — a named stack avoids that surprise.

Edge Cases & Pitfalls

Stacks fail quietly. Quote carefully and keep a generic at the end.

quotes

Spaces need quotes

Times New Roman without quotes is invalid. Use "Times New Roman". Never quote generics like sans-serif.

fallback

Always keep a generic

A named-only stack can fall through to an unexpected default. End with serif, sans-serif, or monospace.

mono size

Lone monospace can look smaller

Browsers may apply a smaller preferred mono size when the value is only monospace. Prefer a short named stack, or set font-size explicitly.

system-ui

system-ui is for UI, not essays

It matches the OS control font. For long reading text, prefer a body stack ending in sans-serif or serif.

glyphs

Selection is per character

If the first font lacks a glyph, later fonts in the stack can fill in that character.

Browser Support

font-family is a browser style property. Node.js, Deno, and Bun do not apply it. Core stacks are universal; some newer generics are not.

✓ Baseline · Widely available

font-family

Chrome 1+, Firefox 1+, Safari 1+, Edge 12+, Opera 3.5+, Internet Explorer 3+. system-ui needs newer engines (Chrome 56+, Safari 11+, Firefox 92+).

99% core support
Google Chrome 1+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 1+
Full support
Microsoft Edge 12+
Full support
Opera 3.5+
Full support
Samsung Internet 1+
Full support
Internet Explorer 3+
Full support
font-family Universally supported; newer generics vary

Bottom line: Safe for production. Keep classic generics in every stack so newer keywords like math or ui-* are optional enhancements.

Key Takeaways

  • Role: choose typefaces in priority order.
  • Stack: named fonts first, generic last.
  • Quotes: use for spaced names; never for generics.
  • Inherited: set on a parent to style whole sections.

One line: font-family is a prioritized font list that should end with a generic fallback.

Frequently Asked Questions

It sets a prioritized list of typefaces. The browser uses the first installed (or downloadable) font that can draw each character.
Named fonts may be missing. A generic like sans-serif or serif guarantees a similar style of fallback.
Quote names with spaces, digits, or punctuation other than hyphens — for example "Times New Roman". Generics must never be quoted.
A comma-separated list from preferred to fallback fonts, usually ending with a generic family.
font-family only chooses the typeface. The font shorthand can also set size, weight, style, and line-height together.
It is Baseline widely available: Chrome 1+, Firefox 1+, Safari 1+, Edge 12+, Opera 3.5+, Internet Explorer 3+. It is a browser style property, not a Node.js feature.

Next: font-feature-settings

Tune OpenType features when a font supports them.

font-feature-settings tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful