font-display
Embed This Widget
Add the script tag and a data attribute to embed this widget.
Embed via iframe for maximum compatibility.
<iframe src="https://fontfyi.com/iframe/glossary/font-display/" width="420" height="400" frameborder="0" style="border:0;border-radius:10px;max-width:100%" loading="lazy"></iframe>
Paste this URL in WordPress, Medium, or any oEmbed-compatible platform.
https://fontfyi.com/glossary/font-display/
Add a dynamic SVG badge to your README or docs.
[](https://fontfyi.com/glossary/font-display/)
Use the native HTML custom element.
A CSS descriptor that controls how a web font is displayed during loading. Values: auto, block, swap, fallback, optional.
font-display is a CSS descriptor used inside @font-face rules to control exactly how a browser handles font loading — specifically, what to show users while a web font is downloading. It's one of the most impactful single properties for web typography performance and a key lever for improving Core Web Vitals scores.
The descriptor accepts five values, each representing a different strategy along the spectrum from "show nothing" to "always show something":
@font-face {
font-family: 'Nunito';
src: url('/fonts/nunito.woff2') format('woff2');
font-display: swap; /* Most common choice for body text */
}
The five values:
/* block — invisible text for ~3s, then swap (FOIT) */
font-display: block;
/* swap — show fallback immediately, swap when ready (FOUT) */
font-display: swap;
/* fallback — ~100ms invisible, then fallback, swap if font arrives quickly */
font-display: fallback;
/* optional — ~100ms invisible, then fallback, no swap (font cached for next visit) */
font-display: optional;
/* auto — browser decides (usually same as block) */
font-display: auto;
font-display: swap is the Google Fonts default and the right choice for most body text. It eliminates invisible text (FOIT) by immediately rendering a fallback font, then swapping when the web font arrives. The trade-off is a visible style change — manageable with fallback font metric adjustments.
font-display: optional is the most performance-friendly option. The browser shows the fallback if the font isn't available within a very short window, and never performs a late swap — eliminating CLS entirely. The font downloads silently in the background and is used on subsequent page loads once cached. This is ideal for non-critical decorative fonts.
font-display: fallback splits the difference: a tiny invisible window (~100ms, imperceptible to users), then a fallback font, with a swap only if the font arrives within a reasonable time window (typically 3 seconds). It's a good choice when you want to avoid both long invisible periods and very late jarring swaps.
When using Google Fonts via their CDN URL, you can enable swap with a simple parameter:
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
For self-hosted fonts with performance budgets, optional combined with preloading gives the best LCP and zero CLS:
@font-face {
font-family: 'Source Sans 3';
src: url('/fonts/source-sans-3.woff2') format('woff2');
font-display: optional;
}
Understanding font-display is fundamental to any serious web font performance strategy. It directly affects three user experience dimensions: when text first appears, whether layout shifts occur, and how consistent the visual experience feels across connection speeds.
相关术语
相关工具
展示此概念的字体
了解更多
面向初学者的完整指南,教你如何为网站添加 Google Fonts——使用 @import、link 标签以及 Google Fonts API。
网页性能使用 <link rel=preload> 告诉浏览器哪些字体最重要。减少 FOUT,改善 LCP,并理解预加载何时有帮助、何时有害。
网页性能字体加载是累积布局偏移(CLS)的一个隐藏来源。学习 size-adjust、字体指标覆盖,以及消除字体相关 CLS 的策略。
CSS 排版关于 @font-face 的一切——语法、格式选择、unicode-range 子集化、font-display 策略,以及自托管与 CDN 的对比。