</div><table><tbody><tr><td><div><div>2</div><div>4</div><div>6</div><div>8</div></div></td><td><div><div><span><</span><span>html</span><span>></span></div><div><span><</span><span>meta </span><span>charset</span><span>=</span><span>utf</span><span>-</span><span>8</span><span>/</span><span>></span></div><div><span><</span><span>link </span><span>href</span><span>=</span><span>'http://fonts.googleapis.com/css?family=Average Courgette'</span><span>rel</span><span>=</span><span>'stylesheet'</span><span>type</span><span>=</span><span>'text/css'</span><span>></span></div></div></td></tr></tbody></table><p>Next, jump over to the CSS. What we’re going to do here is pretty different than what we saw above. Here’s the code:</p><div><textarea wrap='soft' readonly='>h1 { font: 400 45px/0.5 'Courgette', Helvetica, sans-serif;}p { font: 400 14px/1.5 'Average', Times, serif;}
2 4 6 | font:40045px/0.5'Courgette',Helvetica,sans-serif; font:40014px/1.5'Average',Times,serif; |
First, I used the CSS font shorthand to save some room. This allows us to type in all of the characteristics of our font on a single line which is great.
The first value you see is “400” in both the h1 and the paragraph. I inserted this to make sure that the browser is showing these fonts at the weights that they were meant to be displayed at, and we saw earlier that the intended weight is 400.
Next, I set the font size followed but the line height. Notice that I didn’t use any sort of units for the line-height, this is a neat trick that will apply a relative line-height that changes with the font-size.
Finally, I insert the Google fonts and use my own backups because I don’t think you should ever use the default browser choices for “cursive,” which is what Google uses in its snippet.
That’s really all we need to do. Load up your live preview in a browser and you should see your custom fonts being perfectly displayed.
You’ve just learned all about how to use Google Web Fonts, now it’s time to get out there and put this knowledge to use in your own site. Browse through the available fonts and think about how you can improve the typography in your projects. Always remember that, with custom fonts, less is more. Go easy and use this tool selectively.
If you’re having trouble choosing, be sure to check out our collection of 10 Great Google Font Combinations You Can Copy (also hit up part two!).
Google Fonts is a library of over 800 different typefaces, completely ready to be embedded in your web project. This series looks at what Google Fonts is, and shares interesting examples and combinations of fonts that can take your project to the next level.