font-display swap vs block: timeline and comparison table

PublishedToolfont-display Code Generator

Contents
  1. Why font-display values are confusing
  2. How to check the spec yourself, without a tool
  3. The spots people usually trip on when reading the timeline
  4. Recap
  5. Frequently Asked Questions

The five font-display values differ in two ways: how long they hide text (the block period) and how long after showing a fallback font they can still swap in the custom font (the swap period).

The swap value is especially confusing because the table lists its swap period as "infinite (∞)." That doesn't mean the text is invisible. It means the opposite: the fallback font is showing from the very start.

This post covers what the block period and swap period mean for each of the five values, and where FOUT and FOIT fall on the timeline, based on the CSS spec and how our tool displays it.

Which value you should pick depends on your site, so this post doesn't cover that.

Summary ① The block period is the stretch where text is invisible (FOIT), and the swap period is the stretch where the fallback font is showing and can still be replaced (FOUT). ② The "infinite (∞)" swap period of the swap value doesn't mean the font never shows. It means that no matter how late the font loads, it gets swapped in the moment it arrives. ③ The font name and URL you enter only affect the generated code at the bottom. The block/swap durations and timeline proportions are fixed reference data for the font-display value you selected.

Why font-display values are confusing

While working on the front end, you've probably seen Lighthouse's "Ensure text remains visible during webfont load" warning and added font-display: swap to your CSS.

Then you reload the page and watch the text appear briefly in a fallback font before switching to the custom font.

If you open the table in MDN or the CSS spec at that point, you'll find terms like "Block Period" and "Swap Period" sitting next to numbers like 3s, 100ms, and ∞ (infinite). Without an explanation, it's easy to lose track of which value hides text longer.

"Infinite" in particular invites a backwards reading. A shorter block period is the good direction — text shows sooner. But the phrase "infinite swap period" alone makes people think "invisible forever."

How to check the spec yourself, without a tool

How font-display behaves follows the font display timeline defined by the W3C CSS Fonts Module Level 4 spec. That timeline splits into three periods from the moment the font is requested.

  • Font block period: During this period, if the font hasn't loaded yet, the text stays invisible. If the load finishes inside this period, the custom font is rendered immediately.
  • Font swap period: This period starts when the block period ends. From here on, the text is shown in a fallback font even if the font still isn't available, and if the load finishes inside this period, the custom font replaces it.
  • Font failure period: If the font hasn't loaded by the end of the swap period, the load is treated as a failure, and the fallback font is used for the rest of this page view.

The spec defines recommended values for how long each value sets the block and swap periods.

font-display valueBlock period (spec recommendation)Swap period (spec recommendation)
autoBrowser's own policy (usually similar to block)Browser's own policy
blockShort (about 3 seconds)Infinite
swapExtremely short (about 100ms or less, effectively immediate)Infinite
fallbackExtremely short (about 100ms or less)Short (about 3 seconds)
optionalExtremely short (about 100ms or less)None (0 seconds)

Even this table alone lets you work out the differences between the five values by hand.

Both block and swap have an infinite swap period, so once the font loads it always gets swapped in eventually. The difference is that block hides text for up to 3 seconds first, while swap barely hides it at all and shows the fallback font right away.

Note that the tool below shows the block period for swap as "0s" and the block period for block as "3s." It rounds the spec's recommended "100ms or less" down to effectively zero.

Check it with our tool.

font-display Code Generator

Just enter a font name and URL to see the block and swap periods, timeline, and @font-face code for each font-display value for free.

The spots people usually trip on when reading the timeline

These four points are the easiest to get wrong when reading the table and the timeline.

  • "Infinite swap period" does not mean "invisible": With the swap value, the block period is effectively gone (0s), so text shows in the fallback font from the start. An infinite swap period means the door stays open to swap in the custom font the moment it loads, however late that is. It does not mean the text stays invisible forever.
  • FOIT and FOUT happen in different periods: FOIT (Flash of Invisible Text) happens in the block period, when the text isn't rendered at all. FOUT (Flash of Unstyled Text) happens in the swap period, when text that was showing in the fallback font changes to the custom font.
  • "0s" for optional does not mean "instant swap": It means "no swap happens at all during this page view," not "it swaps instantly in 0 seconds." Once the block period (about 100ms) passes, the fallback font is locked in, and a custom font that finishes downloading after that is applied on the next visit.
  • The input values and the reference numbers are unrelated: Changing the font name or URL only changes the @font-face code text at the bottom of the screen. The Block Period and Swap Period numbers and the timeline bar proportions above are fixed reference data for the selected font-display value, so they look the same no matter what you enter.
font-display valueHow text appears with this valueCommon point of confusion
swapShown in the fallback font right away (FOUT possible)Reading the "infinite" swap period as "invisible"
blockInvisible for up to 3 seconds (FOIT), then switches to the fallback fontThe fallback font only appears once the block period ends
fallbackInvisible very briefly, then the fallback font; after 3 seconds it's locked in for this loadReading "locked in" as "load failed"
optionalChecked very briefly, then locked to the fallback font with no swapReading the "0s" swap period as "instant swap"

Recap

  1. The block period is the stretch where text is invisible (FOIT), and the swap period is the stretch where the fallback font is showing and can still be replaced (FOUT).
  2. With the swap value, the block period is effectively 0, so text shows in the fallback font immediately, and the infinite swap period means it can be swapped in the moment it loads.
  3. With the block value, text is hidden for up to 3 seconds before the fallback font appears, and after that it can be swapped in indefinitely, just like swap.
  4. fallback and optional put a cap on the swap period (about 3 seconds and 0 seconds respectively), so once that time passes, nothing more is swapped in for this page view.
  5. The font name and URL you enter only affect the generated code text. The block/swap durations and timeline proportions are fixed reference data for the selected value.
font-display Code Generator

Just enter a font name and URL to see the block and swap periods, timeline, and @font-face code for each font-display value for free.

Frequently Asked Questions

If the swap period is "infinite (∞)," does that mean the font never shows up?

No. An infinite swap period doesn't mean the text stays invisible forever. It means that no matter how late the custom font loads, the fallback font can switch to the custom font the moment it loads.

In fact, the swap value has essentially no block period, so the text is visible right from the start.

What exactly is the difference between FOUT and FOIT?

FOIT (Flash of Invisible Text) is when the text itself isn't rendered during the block period, so you can't see it.

FOUT (Flash of Unstyled Text) is what happens during the swap period, when text shown in the fallback font switches to the custom font. The block value makes FOIT more noticeable, and the swap value makes FOUT more noticeable.

Which value does auto behave the same as?

By spec, auto is defined to follow the browser's own policy, so it isn't fixed to any one value. That said, most major browsers — Chrome, Safari, Firefox, and others — are known to handle auto much like block.

Does the generated @font-face code also reflect the font-weight or font-style I entered?

No. In the generated code, font-family and src (the URL) reflect exactly what you entered, but font-weight is fixed at 400 and font-style at normal.

If you're using a font with a different weight or style, you'll need to edit those values directly in the code you copied.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. @font-face CSS: woff2, woff, ttf src order and syntaxLearn how to write @font-face rules: why src goes woff2, woff, ttf, when font-family needs quotes, and how font-display: swap works.
  2. Check My Latitude and Longitude, Including Accuracy RadiusSee how the browser Geolocation API estimates your position from GPS, Wi-Fi, and cell signals, and what the accuracy, altitude, and speed values mean.
  3. How to Read a Hex Dump: Offsets, Hex Bytes, and ASCIILearn what the three hex dump columns mean — offset, hex bytes, and ASCII — why the offset looks different in hex or decimal, and why dots appear.
  4. HMAC-SHA256 Signature Verification: Check Your ValuesLearn why an HMAC-SHA256 signature doesn't match your calculated value, and how to recompute it yourself to compare character by character.
  5. HTML Email Preview: Check Mobile and Desktop RenderingSee how your HTML email code renders at 375px, 768px, and full width in the browser, and why table layouts and inline styles hold up better in inboxes.
  6. HTML Entity Conversion: 5 Character Encoding RulesSee how HTML entity conversion works: which entities replace five special characters, and how to decode numeric and named entities back to text.

Related tools