At the end of this Tutorial you will be able to:
You can view finished versions of the four sample web pages you will update with Google Fonts in this Tutorial by clicking the links below. The finished samples will each open in a new tab of your web browser.
You created these four sample web pages and their linked stylesheets in the previous Introduction to Images Tutorial.
One: Making the Google Font available to your web page
Two: Updating the <font-family> in your CSS file
Working with the van Gogh sample web page
Working with the Tourism sample web page
Working with the Smoothies sample web page
Working with the Software sample web page
Google Fonts offers the Internet’s largest collection of open-source, royalty-free fonts. All 900-plus fonts can be used without restriction for personal, not-for-profit or commercial web projects.
Below is a screenshot of the Google Fonts home page at:
To preview a particular font, click on it. To see how a few words of text will look when styled in the selected font, type your chosen text in the Type here to preview text box.
There are two basic steps to using Google Fonts. They are as follows.
In this first step, you add a line similar to the following to the <head> of your HTML file.
In this example, the name of the Google Font is ‘Roboto’.
For every Google font, the text within the href="" attribute follows the same format. Only the name of the font is different.
Here are some more examples, showing only the href="" part for readability.
If the Google Font you want to use has more than one word in its name, you need to add a plus sign (+) between the words. See the examples below for the fonts named ‘Open Sans’ and ‘Source Sans Pro’.
Your second step to using a Google Font is to add the font name to the font-family property of the relevant heading or paragraph text selector within your stylesheet.
For example, to use the ‘Kinsta’ font for your <h1> headings, you would edit the h1 selector in your CSS file as follows.
To use the ‘PT Sans’ font for your <h3> headings, you would edit the h3 selector in your CSS file as follows.
And if you wanted to use the ‘Work Sans’ font for your text paragraphs, you would edit the p selector in your CSS file as follows.
Note that the font name is always wrapped in a pair of single quotation marks (‘ ’).
You can also see that every Google Font name is followed by a comma (,) and what is called a fallback font – either serif or sans-serif. This is the font that is displayed when the web page is viewed without a live Internet connection.
As with much else, there are fashions and trends in fonts. Here are the more widely-used serif and sans-serif fonts at the moment.
In this section, you will work with the sample page-5.html web page and the sample style-5.css stylesheet.
<!-- Google Font --> <link href="https://fonts.googleapis.com/css2?family=Merriweather&display=swap" rel="stylesheet">
Click page-5.html to view a finished sample of this web page in a new tab of your web browser.
In this section, you will work with the sample page-6.html web page and the sample style-6.css stylesheet.
<!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Oswald&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">
Click page-6.html to view a finished sample of this web page in a new tab of your web browser.
In this section, you will work with the sample page-7.html web page and the sample style-7.css stylesheet.
<!-- Google Font --> <link href="https://fonts.googleapis.com/css?family=Neucha&display=swap" rel="stylesheet">
Click page-7.html to view a finished sample of this web page in a new tab of your web browser.
In this section, you will work with the sample page-8.html web page and the sample style-8.css stylesheet.
<!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Domine&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=PT+Sans&display=swap" rel="stylesheet">
Click page-8.html to view a finished sample of this web page in a new tab of your web browser.
After finishing your web pages and stylesheets, you are now ready to upload them to your account on GitHub.
Your web pages and stylesheets are now published on GitHub at web addresses similar to the following, where username is the username you have chosen for your GitHub account:
https://username.github.io/websites/page-5.html
https://username.github.io/websites/page-6.html
https://username.github.io/websites/page-7.html
https://username.github.io/websites/page-8.html
It may take a few minutes for your uploaded files to appear on GitHub.
How to: Google Fonts
from W3 Schools
Get Started with the Google Fonts API
from Official Google Developer Blog
93 most popular premium fonts: free Google Font alternatives
from Design Way
25 Most Popular Google Fonts - 2020
from UX Planet
The Ultimate Collection of Google Font Pairings
from Reliable PSD
Top 10 Beautiful Google Font Combinations in 2020
from Linkbot Design
Return to Contents.