font-display

Summary

The font-display descriptor determines how a font face is displayed based on whether and when it is downloaded and ready to use.

The Font Display Timeline

The font display timeline is based on a timer that begins the moment the user agent attempts to use a given downloaded font face. The timeline is divided into the three periods below which dictate the rendering behavior of any elements using the font face.

Font block period
If the font face is not loaded any element attempting to use it must render an invisible fallback font face. If the font face successfully loads during this period, it is used normally.
Font swap period
If the font face is not loaded any element attempting to use it must render a fallback font face. If the font face successfully loads during this period, it is used normally.
Font failure period
If the font face is not loaded the user agent treats it as a failed load causing normal font fallback.

Related at-rule@font-face
Initial valueauto
Mediavisual
Computed valueas specified
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

/* Keyword values */
font-display: auto;
font-display: block;
font-display: swap;
font-display: fallback;
font-display: optional;

Values

auto
The font display strategy is defined by the user agent.
block
Gives the font face a short block period and an infinite swap period.
swap
Gives the font face no block period and an infinite swap period.
fallback
Gives the font face an extremely small block period and a short swap period.
optional
gives the font face an extremely small block period and no swap period.

Formal syntax

[ auto | block | swap | fallback | optional ]

Examples

@font-face {
  font-family: ExampleFont;
  src: url(/path/to/fonts/examplefont.woff) format('woff'),
       url(/path/to/fonts/examplefont.eot) format('eot');
  font-weight: 400;
  font-style: normal;
  font-display: fallback;
}

Specifications

Specification Status Comment
CSS Font Rendering Controls Module Level 1
The definition of 'font-display' in that specification.
Editor's Draft Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 51.0[1] 46.0 (46.0)[2] ? ? ?
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support ? 46.0 (46.0)[2] ? ? ? No support

[1] Behind a flag.

[2] This feature is available since Firefox 46 behind the preference layout.css.font-display.enabled, defaulting to false.  See (bug 1157064).

Document Tags and Contributors

 Contributors to this page: mfluehr, teoli, Astley, mkato, Sebastianz, jpmedley
 Last updated by: mfluehr,