Learn Beginner

How to use Google Fonts in your next web design project

How to use Google Fonts in your next web design project

Google fonts are an awesome way of adding a cool font to your website, I use them in 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 on our 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 Review and 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
  • @import this imports it directly in the CSS

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 is a question that keeps floating around on the internet, and Steve Souders did an excellent job of comparing the two. As his article title suggests,is the best way to go according to him and Yahoo.

Using the Google Font on our website

<head>
  <link
    href="https://fonts.googleapis.com/css2?family=Amatic+SC:wght@700&display=swap"
    rel="stylesheet"
  />
</head>

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:

h1 {
  font-family: 'Amatic SC', cursive;
}

It’s important to use the name as stated in Google Fonts website.

What to think about

So important to note when using Google Fonts, they tend to load slowly, the more you use, 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!

Thank you for reading, and let’s connect!

Thank you for reading my blog, feel free to subscribe to my email newsletter, and ask questions and give your valuable suggestions.

Hiren Vaghasiya

Hiren is an avid technical geek and blog lover. Now a high time tech blogger here, along with Freelancer, Web Designer, Digital Marketer & Sales Funnel Specialist.

1 comment

Learn Beginner

Don't be shy, get in touch. We love meeting interesting learners and making the world's best developers.