Set the descriptor in the font-face rule
W3C defines font-display as a descriptor for the face, with block, swap and failure periods in its loading timeline. For example, add font-display: swap to the same @font-face rule that names the family and source. Keep a fallback family in the element’s font-family list. The descriptor determines display behavior during loading, while the list supplies the alternative family.
Choose how long a late font may replace the fallback
With swap, fallback text can appear quickly and the custom face can replace it when available. The fallback and optional settings limit the opportunity for a later change in different ways. Compare the modes using the same title and body paragraph on a cold load. Watch whether the line breaks move after the face arrives, especially on a narrow screen.
Proof the fallback as a real design
Compare the fallback and final families at their intended sizes. Check buttons, navigation and a long headline while the font is missing. Match basic proportions when possible and give labels space to wrap. The font-face guide covers registration. Try the homepage copyable text chooser for separate Unicode styles unrelated to loading a webfont.
Your questions, answered.
Is font-display a property on the heading?
Set it on the font face. Use font-family on the heading or other element to choose the face.
Can font-display prevent every layout shift?
It controls display timing. If the faces have different widths or heights, a replacement can still change the layout.
Sources & background
Sources supporting this page’s explanations. Practical examples are our editorial suggestions.