CSS Font-display and how to use it

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Math assignment help was the reason i scored 90% in my internals during my school in this subject. Math always bothered me in my schooldays but, still it was compulsory to pass in all the subjects and the minimum to pass was50% in internals. And, I was sure that I won't get it on my own. If you feel same then visit this platform.
if you are a Finance student then you know it is one of those subjects which needs constant attention. But nowadays, students are not investing much time in their studies. Thus to overcome this problem the students often look for finance assignment help. Where they can get help from experts, they offer the best quality help for students. Visit: https://www.financeassignmenthelp.com/
I am searching for the CSS Font display and how to use it and I am glad I have found your post. Thanks for sharing it with us. I have also found the https://masterbundles.com/fonts/sans-serif/outline/ website on google in which I have found ideas related to sans serif fonts. You have explained it very well and it is easy for me to understand your post.
Glad you enjoyed it Russel
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

Yesterday we included a custom Google Font on our website and briefly mentioned the font-display option.
Let's dive deeper into what it is and how it works.
As we saw yesterday, custom fonts tend to load slowly and block the browser from defining when your website is ready. This, in turn, makes Google think your website is slow, and nobody wants that.
So in modern browsers, we can use the font-display function.
auto: This is the default value, and leaves the decision up to the browser, in most cases, it will be blockblock: This tells the browser to hide the text until the font has fully loaded. This is the flash you see when it swaps on some sites.swap: Swap, as the name suggests, will start with the fallback font and swap once the font is loaded.fallback: This is a compromise between auto and swap. It will start with hiding the font for a brief period and then go into the swap routine.optional: This is much like the fallback method. It tells the browser to start with a hide and then transition into the fallback font. The nice option here is that it allows the browser to see if the custom font is even used at all. If, for instance, a slow connection appears, they are less likely even to see the custom font.As seen in the previous example, we can use it as such:
h1 {
font-size: 40px;
font-family: 'Amatic SC', cursive;
font-display: swap;
}
So we talked about fallback fonts quite a bit, but what are those even?
h1 {
font-family: 'Amatic SC', 'Times New Roman', Times, serif;
}
So in the above example, the custom font is Amatic SC the system font is Times New Roman or Times, so in the case of using swap, we will first see Times New Roman and when the custom font has loaded it will show Amatic SC.
Not all browsers support this, but I encourage you to use font-display. The browsers that don't support it will decide for you.

Thank you for reading my blog, feel free to subscribe to my email newsletter and connect on Facebook or Twitter