Course contentsShow
← Web Development
Lesson 569 of 2,98210. Typography and Design SystemsFree lesson

Fallback Font Stacks

Define robust fallback font stacks to maintain readability and minimize layout shift during font loading.

Fallback Font Stacks

What you'll learn: How to define backup fonts that keep your text readable when custom fonts fail to load or aren't available.


What Is a Fallback Font Stack?

A fallback font stack is a prioritized list of fonts in your CSS. The browser tries the first font; if it's unavailable (still loading, failed, or not installed), it immediately moves to the next option, and so on. This prevents blank text (FOIT) and minimizes visual disruption during font loading.

Think of it like a restaurant order: "I'll have the salmon, but if you're out, give me chicken, or worst case, a salad." You get something appropriate, not nothing.

Why Robust Stacks Matter

When you use web fonts, there's always a loading delay—even milliseconds matter. Without good fallbacks, your page might:

  • Show invisible text (if font-display: block)
  • Display text that suddenly jumps when the custom font loads (layout shift)
  • Look broken if the font service fails

A well-matched fallback uses system fonts with similar metrics (size, weight, spacing) to your web font, reducing "flash" when the switch happens.

Building a Good Stack

body {
  font-family: 'CustomFont', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

Order matters:

  1. Your web font (CustomFont)
  2. Close system matches (Helvetica Neue on macOS/iOS)
  3. Wider availability (Helvetica, Arial)
  4. Generic family (sans-serif as ultimate fallback)

For serif fonts, end with serif; for monospace, use monospace. Always include that generic keyword—it tells the browser's default category if all else fails.

Matching Metrics

Choose fallbacks with similar x-height and letter-spacing to your web font. Tools like FontStyle Matcher can help you adjust fallback fonts to minimize layout shift.


Key Takeaway: A robust fallback font stack ensures readable text at all times by listing progressively more available fonts, minimizing both loading delays and visual disruption.