# font-display

> The `font-display` CSS descriptor of `@font-face` specifies how a custom font is displayed while it's downloading or when it fails to load.

## What does font-display: swap do in CSS?

The `@font-face` descriptor that defines how a web font is shown while it loads or if it fails. Values 'auto', 'block', 'swap', 'fallback' and 'optional' trade between invisible text, a fallback font flash and layout stability.

- Topic: Text Handling
- Type: property
- Browser support: Chrome 60+, Chrome Android 60+, Edge 79+, Firefox 58+, Firefox Android 58+, Safari 11.1+, Safari iOS 11.3+

## Example

Wrong:

```css
body {
  font-family: "Brand", sans-serif;
  font-display: swap;
}
```

Right:

```css
@font-face {
  font-family: "Brand";
  src: url("brand.woff2") format("woff2");
  font-display: swap;
}
```

`font-display` is a descriptor of `@font-face`; as a regular property on `body` it is ignored.

## Common mistakes

- Text is invisible for a few seconds on slow networks because the default is `auto`.
- The layout jumps when the web font swaps in, because the fallback font has different metrics.

## Key points

- `font-display` is set inside each `@font-face` block, not on regular selectors.
- Web fonts use `swap` or `optional` so text is visible while the font loads.
- Critical fonts are preloaded with `crossorigin`, so the swap happens early.

## Interview questions

### font-display swap vs optional?

`swap` shows fallback text and always switches when the font loads. `optional` uses the font only if it arrives almost immediately, avoiding a late layout shift.

### Does font-display: swap cause layout shift?

It can, when the fallback and web font differ in size. Tune the fallback with `size-adjust` in `@font-face` to reduce it.

## Related cards

- [@font-face](https://wonderium.dev/css/font-face.md)
- [font-family](https://wonderium.dev/css/font-family.md)
- [CLS](https://wonderium.dev/web/cls.md)
- [\[rel="preload"\]](https://wonderium.dev/html/rel-preload.md)
- [LCP](https://wonderium.dev/web/lcp.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/font-display
- Last updated: 2026-11-25
