Introducing CSS’ new font-display property

Default avatar.
August 23, 2016
Introducing CSS’ new font-display property.

We take web fonts for granted these days. We didn’t always have the option of setting our text in almost any typeface. I mean, we could, but then we’d have to sigh and say, “Well, that’ll look good on about five people’s computers. Hope everyone else likes Verdana!”

Web fonts brought some much needed variety to the seen, a few abuses of typography, some extra page weight as the fonts themselves were loaded, and flashes of unstyled or invisible text. Well… omelette, eggs, breaking, you get the idea. It was bound to happen. [pullquote]If users are stuck looking at a blank page for too long they might just decide to leave[/pullquote] It’s a bit of a usability problem, though, when text is invisible until the custom font gets loaded. If users are stuck looking at a blank page for too long (and too long might be milliseconds) they might just decide to leave. And that’s fair enough. It’s not user-friendly. Fast forward a few years, and we’re making progress on controlling the way fonts load. Until now, we’ve done it with third-party libraries and APIs. But now, at last, this functionality is coming to CSS. Enter the font-display property. It’s currently only in Opera, Opera for Android, and Chrome. (It was first introduced in Chrome 49 as an experimental feature.) It comes with four options: auto, swap, fallback, and optional. Basically, choosing font-display: auto will leave the browser to act as it does now. Text will be invisible until the custom font loads. swap is probably what most people will use. If the font isn’t loaded, the next available font defined in the font-family property will be used. When the web font loads, it will be replaced. This is basically a flash of unstyled content, but that’s more user-friendly than invisible content, I think. fallback splits the difference between those first two options. For a delay of 100 milliseconds, the text will be invisible. If the custom font is loaded by then, it will be used. If not, the next font in the line of succession will rule until the custom font is loaded. [pullquote]optional works like fallback, except the browser may decide not to load the custom font at all, if the user’s connection is too slow[/pullquote] optional works like fallback, except the browser may decide not to load the custom font at all, if the user’s connection is too slow. And there we have it. Mind you, the display-font is meant to be used in a @font-face declaration. That means it won’t work with third-party font providers like Typekit or Google Fonts for now. Once font-display becomes more widespread, however, it’s likely that they’ll implement some sort of option for this feature.

Ezequiel Bruni

Ezequiel Bruni is a web/UX designer, blogger, and aspiring photographer living in Mexico. When he’s not up to his finely-chiselled ears in wire-frames and front-end code, or ranting about the same, he indulges in beer, pizza, fantasy novels, and stand-up comedy.

Read Next

10+ Best Resources & Tools for Web Designers (2024 update)

Is searching for the best web design tools to suit your needs akin to having a recurring bad dream? Does each…

3 Essential Design Trends, April 2024

Ready to jump into some amazing new design ideas for Spring? Our roundup has everything from UX to color trends…

How to Plan Your First Successful Website

Planning a new website can be exciting and — if you’re anything like me — a little daunting. Whether you’re an…

15 Best New Fonts, March 2024

Welcome to March’s edition of our roundup of the best new fonts for designers. This month’s compilation includes…

LimeWire Developer APIs Herald a New Era of AI Integration

Generative AI is a fascinating technology. Far from the design killer some people feared, it is an empowering and…

20 Best New Websites, March 2024

Welcome to our pick of sites for March. This month’s collection tends towards the simple and clean, which goes to show…

Exciting New Tools for Designers, March 2024

The fast-paced world of design never stops turning, and staying ahead of the curve is essential for creatives. As…

Web Tech Trends to Watch in 2024 and Beyond

It hardly seems possible given the radical transformations we’ve seen over the last few decades, but the web design…

6 Best AI Productivity Apps in 2024

There’s no escaping it: if you want to be successful, you need to be productive. The more you work, the more you…

3 Essential Design Trends, February 2024

From atypical typefaces to neutral colors to unusual user patterns, there are plenty of new website design trends to…

Surviving the Leap from College to Real-World Design

So, you’ve finished college and are ready to showcase your design skills to the world. This is a pivotal moment that…

20 Mind-Bending Illusions That Will Make You Question Reality

Mind-bending videos. Divisive Images. Eye-straining visuals. This list of optical illusions has it all. Join us as we…