Font Stack
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-stack/" 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-stack/
Add a dynamic SVG badge to your README or docs.
[](https://fontfyi.com/glossary/font-stack/)
Use the native HTML custom element.
An ordered list of fonts in CSS font-family, providing fallbacks if the preferred font is unavailable. E.g., 'Inter, system-ui, sans-serif'.
A font stack is the ordered list of font families in a CSS font-family declaration. The browser works through the list from left to right, using the first font that is available on the system or has been loaded. The later entries in the stack are fallbacks — they serve when preferred fonts aren't available.
/* Classic font stack */
body {
font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
}
Here, Inter is tried first. If unavailable, Helvetica Neue is used. If that's missing, Arial. If all named fonts fail, the browser uses its default sans-serif.
Generic font families (always last in the stack):
The final entry in any stack should be a generic keyword — serif, sans-serif, monospace, cursive, or system-ui. These are not specific fonts; they're instructions to the browser to use its default font in that category. They never fail.
/* Complete stacks for common use cases */
/* Sans-serif body text */
body {
font-family: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
}
/* Serif editorial */
.article {
font-family: 'Lora', Georgia, 'Times New Roman', serif;
}
/* Monospace code */
code {
font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code',
'Consolas', 'Courier New', monospace;
}
System font stack:
For interfaces that should feel native to the operating system, the system font stack uses each OS's default UI font:
body {
font-family:
system-ui,
-apple-system, /* Safari on macOS/iOS */
BlinkMacSystemFont, /* Chrome on macOS (legacy) */
'Segoe UI', /* Windows */
Roboto, /* Android/Chrome OS */
'Helvetica Neue', /* Older macOS */
Arial, /* Universal fallback */
sans-serif;
}
GitHub, Linear, and many developer tools use system font stacks to reduce load times and match platform conventions.
Fallback font metrics — reducing layout shift:
When a web font loads and replaces a fallback, differences in the fonts' metrics (x-height, line-height, character width) cause layout shift. CSS allows overriding fallback font metrics to match the web font:
/* Override fallback metrics to match Inter */
@font-face {
font-family: 'Inter-fallback';
src: local('Arial');
ascent-override: 90%;
descent-override: 22.43%;
line-gap-override: 0%;
size-adjust: 107.64%;
}
body {
font-family: 'Inter', 'Inter-fallback', sans-serif;
}
Tools like Fontaine and Next.js's next/font module generate these adjusted fallback declarations automatically, making them practical to use without manual metric measurement.
相关术语
相关工具
展示此概念的字体
了解更多
为 Tailwind CSS 添加 Google Fonts 或自定义字体——扩展 font-family 主题、高效加载字体,以及 Tailwind 排版的最佳实践。
字体评测邮件排版仍受限于客户端支持。最适合邮件的字体——网页安全默认选项、托管字体的变通方法,以及万无一失的回退方案。
字体评测在未经训练的眼中,它们几乎一模一样。但 Arial 与 Helvetica 存在关键差异——背后还有一段复杂的模仿与竞争史。
网页性能字体加载是累积布局偏移(CLS)的一个隐藏来源。学习 size-adjust、字体指标覆盖,以及消除字体相关 CLS 的策略。