Using Google Fonts on your website
Today I came across a blog post by Divyang Patel discussing the use of the Google Font API on your web site.
Since most of my development is done inside of the University world I never paid much attention to using this technique so I decided to implement it on my company web site.
I was amazed at how easy this was to add to your page. The great thing about it is you don’t have to be a web developer guru to implement the code. Simply add a stylesheet link to reference the library.
|
1 |
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Noble"> |
Notice the reference to Noble in the above line. This tells your web page to load the font family Noble from the list of available fonts from Google. Simply change Noble to your desired font.
To insert fonts with spaces in the names, just add a ‘+’ between text.
[text light="true"]
http://fonts.googleapis.com/css?family=Droid+Sans
[/text]
The next step is to apply it to your styles in your stylesheet. For simplicity we’re going to apply it to the body tag but you can apply it to any css selector.
|
1 2 3 4 |
body { font-family: 'Noble', serif; font-size: 12px; } |
You can also add it to an inline style.
|
1 |
<div style="font-family: 'Font Name', serif;">Your text </div> |
Placing the font name in quotes tells the browser to render text for the css element with the associated Google font.
To cover all bases (in case of errors) always have a fallback web-safe font following the Google typeface. This way if something goes wrong your content will still display to your users in the browsers default font. I suggest sticking with serif and sans-serif.
To add multiple typefaces, add a pipe ‘|’ between families.
[text light="true"]
http://fonts.googleapis.com/css?family=Noble|Inconsolata|Droid+Sans
[/text]
The other cool feature is Google allows you to add font styles (Be sure to check and make sure the typeface you are using has this available style.), Bold, Bold Italic and Italic.
That’s it in a nutshell. Pretty simple huh? Hopefully in the future there will be even more fonts available to use but right now this is a great start towards closing the print and web typography gaps.
Happy coding!

6 Comments
HHWilliam
07.23.2010
Nice post!
Flying Tech
Panama Internet
07.30.2010
The layout for your website is a bit off in Galeon. All The Same I like your web site. I may have to install a “normal” browser just to enjoy it.
tattoo kits
08.01.2010
Hey mate, thanks for writing but this post doesn’t format correctly in Firefox it is showing only half the page.
Bruno Tighe
08.01.2010
Usually I don’t comment, I’m a lurker, but this time I had just to say thanks!
admin
08.01.2010
Seems the pre and td tags had no color associated with the font. Should display fine now.
Clara
11.02.2010
Hello, just doing some browsing for my Hewlett Packard website. Lots of information out there. Not what I was looking for, but great site. Have a nice day.
Windor
10.02.2010
…
Okay posting. I merely found out your blog site and wished to say I have truly liked examining your ideas. By any signifies I’ll be subscribing for a feed and I really hope you publish once more quickly….
There are no trackbacks to display at this time.