Easy Web Fonts with Google Font API

Web fonts allow you to step outside of the normal web-safe fonts by taking advantage of CSS’s @font-face rule. However, right now, browsers aren’t uniform in its implementation of @font-face. More specifically, web browsers differ in the types of font files they support (hopefully this will change with the WOFF standards). Additionally, you must be careful with the fonts you use since some of them might not be licensed for web use.

To sidestep the issues with @font-face, the Google Font API is here to the rescue. Here is an example of using the Cantarell font on elements that takes advantage of Google Fonts API. If you want to use the Cantarell font from Google Font API, first reference the remote stylesheet inside your tags:

href="http://fonts.googleapis.com/css?family=Cantarell"

To use the font in h1 elements, simply use the font-family CSS property.

h1 {
    font-family: 'Cantarell', Arial, serif; /*Use a font stack, just in case.*/
}

 

Advertisements