Free Pretty Web Fonts in 5 Minutes with Google Font API

Learn how to use Google's Font API to install and use nice-looking web fonts in your web pages, in just a few minutes.

Free Pretty Web Fonts in 3 Steps with Google Font API

For years, us web designers and coders were stuck with a pretty poor range of fonts that we could use across all platforms: Times, Arial, Verdana, and a handful more. If you wanted anything more original then you had to create your text as an image in Photoshop.

Well, times they are a-changin', in the form of web fonts. These are online font files that you link to from within your page. The browser downloads the font you linked to, and you can then use that font for text within your web pages, just as if it was a regular system font. Lovely!

Web fonts are really starting to take off now, with services such as Typekit, Font Squirrel and Ascender giving you access to a range of free and paid web fonts.

In this tutorial I'll show you how to use the Google Font API to add nice-looking web fonts to your pages. This service is a relative newcomer to the scene, but it has a couple of big strengths:

  • All the fonts are free
  • It's very easy to use

So, let's see how we can use the Google Font API to add pretty fonts to our web pages — in less than 5 minutes!

Step 1: Choose a font

The first thing to do is browse the Google Font Directory and find a font that you'd like to use. I decided to use Vollkorn for the body text in my demo page.

Click the font you're interested in to view more details of the font, and view specimens at various sizes:

The Google Font Directory font detail page
The Google Font Directory font detail page

Some fonts, such as PT Sans, have several families to choose from. When you click the font in the list, you'll see all the families appear. Just click the family you'd like to use.

Step 2: Embed your chosen font

When you're ready to use the font, click the Get the code link on the font detail page. You can usually select other variants of the font that you'd like to use — such as Light or Bold — by selecting the appropriate checkboxes.

Below the checkboxes, you'll see a line of code that begins:

<link href=' 

For example, my line of code looks like this:

<link href='' rel='stylesheet' type='text/css'>

Copy and paste that line of code into the <head> ... </head> section of your web page — for example:

<!doctype html>
<html lang="en">

<title>Free Pretty Web Fonts with Google Font API</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">

<link href='' rel='stylesheet' type='text/css'>


If you have a static site with regular .html pages then you'll need to paste this line of code into every page of your site where you want to use the font. However, if you're using PHP, ASP or a content management system of some sort then you can just put it in the include file for your page header. For example, in WordPress you can add it to /wp-content/themes/(theme-folder)/header.php.

As well as embedding the font, you can also download the .ttf font files from the font detail page. This is handy when it comes to mocking up your page designs for clients in Photoshop.

Embedding multiple fonts

Want to embed more than 1 web font? Just separate the font family names with the pipe ('|') symbol in your <link> tag. For example, I decided to use the lovely IM Fell DW Pica SC font for my headings, so I simply changed my <link> tag to include this font too:

<link href='|Vollkorn&subset=latin' rel='stylesheet' type='text/css'>

As you can see, if the font name has spaces in it then you need to replace the spaces with '+' signs in the <link> tag. (If you're ever unsure of exactly what to put in your <link> tag, just grab the code for the font as explained in Step 2 above.)

It's best not to have too many web fonts in your page, as they can make the page slower to load. Try to stick to 1 or 2 if you can.

Step 3: Style your text using the font

Now that you've embedded the font, you can use it in your CSS, just like a regular font. For example, I added CSS rules to make the default body text use Vollkorn, and the headings use IM Fell DW Pica SC, as follows:

body {
  font-family: 'Vollkorn', 'Georgia', serif;

h1, h2, h3 {
  font-family: 'IM Fell DW Pica SC', 'Palatino', serif;

It's always a good idea to include browser-safe fonts like Arial, Times or Georgia in your font stack as a fallback, as well as generic fonts such as "serif" or "sans-serif", as I've done above. Here's a useful list of cross-platform browser-safe fonts.

That's really all there is to it! Check out my example page — view the page source if you want to see how it works.

The finished page using the 2 web fonts
The finished page using the 2 web fonts: Vollkorn and IM Fell DW Pica SC.


In this tutorial I've shown you how to embed nice-looking web fonts in your pages using the Google Font API. The nice thing about the API is that you don't need to use any JavaScript at all. You just include the <link> tag, and Google's server does the rest, returning the appropriate CSS rules based on the user's browser. Easy — and it even works in IE6!

If you need more control over the way fonts are loaded, or you want to include fonts from other providers such as Typekit, then you'll need to get your hands dirty with some JavaScript and use the Google WebFont Loader. Fortunately there's some pretty thorough documentation for this on their website.

Have fun!

Follow Elated

Related articles

Responses to this article

7 responses (oldest first):

14-Dec-10 23:26
This looks like a quick and easy way to spice up pages. Thanks for the tute!
15-Dec-10 07:44
What is the browser compatibility effectiveness with this? Does it work with all late version browsers?
15-Dec-10 18:49
@cat: Thanks, glad you liked it!

@GMCDesign: Yes, pretty much anything vaguely modern:
17-Jan-11 04:51
Very very nice! Thank you!
20-Jan-11 13:42
@impelmedia: You're welcome - thanks for the feedback
09-Sep-11 13:05
Pretty slick. Love getting help and ideas from your site.
12-Sep-11 05:34
@john_m: Thanks

Post a response

Want to add a comment, or ask a question about this article? Post a response.

To post responses you need to be a member. Not a member yet? Signing up is free, easy and only takes a minute. Sign up now.

Top of Page