What You'll Learn
You'll discover how font-display: swap ensures text appears immediately using a fallback font while your web fonts download in the background.
The Swap Strategy Explained
With font-display: swap, the browser takes a "content-first" approach: it shows your text immediately using a fallback system font, then swaps in your custom web font once it's ready. There's no blocking period where text stays invisible.
Think of it like this: You're at a restaurant that just ran out of your favorite plate. Instead of making you wait hungry, they serve you a similar dish right away, then swap it out when your original order is ready. You get fed immediately, even if the presentation changes slightly.
When you declare:
@font-face {
font-family: 'CustomFont';
src: url('customfont.woff2') format('woff2');
font-display: swap;
}
The browser will:
- Show text instantly using Arial, Times, or whatever fallback you specified in your
font-familystack - Download your custom font in the background
- Swap in the custom font as soon as it arrives (with no time limit)
When to Use Swap
This strategy is ideal for:
- Body text and content-heavy sites where readability matters most
- News sites, blogs, and documentation where users need information fast
- Any situation where invisible text is worse than a brief font change
The tradeoff? Users may see a quick visual shift (often called a "flash of unstyled text" or FOUT) when the swap happens. But they can read your content right away, which is usually more important than perfect typography.
Key Takeaway: font-display: swap prioritizes immediate text visibility over visual consistency, making it the best choice for content-first websites where readable text matters more than preventing font swaps.