Performance: Font family
Font family affects page load speed and rendering performance by determining which font files the browser must download and how text is painted.
Jump into concepts and practice - no test required
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }body { font-family: 'CustomFont1', 'CustomFont2', 'CustomFont3', serif; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple custom fonts | No extra DOM nodes | 1 reflow after font load | High paint cost due to font glyph rendering | [X] Bad |
| System font stack | No extra DOM nodes | No reflows from font load | Low paint cost, uses native fonts | [OK] Good |
font-family property control on a webpage?font-familyfont-family property sets which font or fonts the browser uses to display text.font-size, color, and letter-spacing.p { font-family: 'Times New Roman', Georgia, serif; }h1 { font-family: Arial, 'Helvetica Neue' sans-serif; }sans-serif should not be quoted.