Course contentsShow
← Web Development
Lesson 1275 of 2,98223. Web Font OptimizationFree lesson

font-display: fallback Strategy

Understand the fallback value's balanced approach with a short block period followed by swap behavior.

What You'll Learn

You'll learn how font-display: fallback offers a middle-ground strategy between blocking and swapping, combining a brief invisible text period with a short window for font swapping.

The Balanced Approach

The fallback value is like a compromise between block and swap. It gives your custom font a very short chance to load while text remains invisible (typically around 100ms), then immediately shows fallback text. But here's the twist: if your web font finishes loading during a brief "swap period" (usually 3 seconds), it will still swap in. After that window closes, the browser sticks with the fallback font for the rest of the page's lifetime.

Think of it like waiting for a friend at a coffee shop: you'll wait invisibly for a moment (the extremely short block period), then order with a substitute companion (fallback font). If your friend arrives within the next few minutes (swap period), great! But if they're really late, you're moving on without them.

The Timeline

  1. Extremely short block period (~100ms): Text invisible, waiting for web font
  2. Short swap period (~3s): Fallback text visible, but will swap if web font arrives
  3. Font becomes "failed": After the swap period, fallback font is permanent for this page visit

When to Use Fallback

Use font-display: fallback when:

  • Custom fonts are important but not essential
  • You want to minimize layout shift (shorter swap period than swap)
  • You prefer showing text quickly over waiting for brand fonts
  • Performance is a higher priority than perfect typography
@font-face {
  font-family: 'BrandFont';
  src: url('brandfont.woff2') format('woff2');
  font-display: fallback;
}

Key Takeaway: font-display: fallback provides balanced font loading with a very brief invisible period followed by a limited swap window, preventing both long text invisibility and indefinite layout shifts.