← #116 Prevent anchor links from disappearing behind a sticky header

Avoid invisible text when loading a font

Topics: CSS, Google Font

It takes time to load a big font. Most browsers will hide texts until the font is loaded completely. This problem is known as flash of invisible text (FOIT).

We can prevent it from happening by asking the browser to use the system font while the custom font is still being loaded. Once the font is loaded, it will replace the system font used earlier.
This phrase is also known as flash of unstyled text (FOUT).

In order to archive it, we can use the font-display style:

@font-face {
font-family: 'Roboto';
font-display: swap;

If you are using Google fonts, then putting the display=swap parameter is the equivalent way:



Fix a typo or suggest an improvement
#118 Display links in the print mode