How to use Google Fonts with CSS Tutorial

Published January 7, 2015 by CSS Newbies.

Googles fonts API “makes it quick and easy for everyone to use web fonts” and is very simple to use. There are many advantages to using Google fonts because you get to use elegant fonts on your website that have been tested on hundreds of browser configurations and googles content delivery system can reassure you that users will always be able to load the fonts.

There’s essentially 2 steps to integrating a Google font into your website. First you include the stylesheet then you assign the font to the elements on your page that you want to use it, and that’s it! There are two more options you can customize to fit your needs if you want additional font styles or character sets.

After you’ve found a font you like from Google Fonts and clicked the quick use button you’ll see 4 options. The first is where you choose your styles, which usually include light, normal, bold, and super bold options. Next you’ll choose your character sets such as latin, greek, and vietnamese. The third step is where you copy the code to include the font on your page. Google gives three options on including the font.

The standard option is your traditional <link> tag that you include in your <head> tag.

<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

The @import option allows you to include the single line in another CSS document that is already included in the <head> of your website.

Finally the Javascript option allows you to include the styling through a javascript function.

The last step is assigning the font families to elements on your page. Assign the font using the font-family tag and the name of the font you selected, just like any other font. Make sure to include a fallback font just to be safe!

font-family: 'Open Sans', sans-serif;

6 Responses

  1. Pingback: Six ways to use CSS with HTML | Lunarium Design

  2. Pingback: CSS Typographic Reset: Step By Step | Lunarium Design

  3. Pingback: 10 Best Free CSS3 Frameworks of Year 2015 | Lunarium Design

  4. villa puncak (reply)

    You’re in reality a good webmaster. The web site loading speed is incredible. It seems that you are doing any distinctive trick. Furthermore, The contents are masterwork. you have performed a magnificent process in this subject!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>