Google fonts are a fantastic way of adding a cool font to your website, I know I’m not using them, but that is for other purposes. I use them on client websites all the time, and they are amazing and simple to use.
Let’s get started on implementing a custom font for your website.
Finding your Google Font
To find a cool font, we can go to the Google Font library and pick one we like.
Once you have found the one you want, open it up you will see the whole set’s letters and Styles.
Google Fonts will allow you to include more styles on your website. In my case, I’m using Amatic SC Bold. Click the
Select this style button for each style you want.
You will see a side menu on the right. It will have a
Embed section; in the embed, we can get the code.
Embedding the Google Font in your website
There are two ways of embedding the font into your website.
<link>attribute; this sets a link like any external stylesheet
@importimports it directly in the
The Google Fonts website will also show you which
font-family rule you must apply to each element you want to have this specific font.
Should I use Link or @import?
This question keeps floating around on the internet, and Steve Souders did an excellent job of comparing the two.
As his article title suggests,
<link> is the best way to go, according to him and Yahoo.
Using the Google Font on our website
We embed the Google Font in the head of our
HTML file using the following code. This is the code you get from Google Fonts.
Then in our
CSS we can do the following:
font-family: 'Amatic SC', cursive;
It’s essential to use the name as stated on Google Fonts website.
We then have the following result:
What to think about
So important to note when using Google Fonts they tend to load slowly. The more you use them, the more load time it will add.
And Google itself will not like that very much. My suggestion is that you keep it to one custom font.
We can use
font-display: swap to not interfere with the load. More on this in another article!