Embedding Google Font to Your WP Blog

How many of you actually tested your website design on different browsers and computers before you launch the site? I bet few of you do. Do you know that what looks good on one OS (for example, Mac) can really look bad on another, such as Windows? The main reason is because the fonts used in the Mac system is not available in the Windows OS. Substitute font is used by the computer (without the font) and this can really screw up your web design. A good way to overcome this is to use a web font that is supported by most browsers, so that your site will look essentially the same regardless which browser or computer you are using.

During the I/O developer conference in June 2010, Google introduced the Google Font – a series of open source font, that you can embed and use on your site. All the fonts are hosted on the Google server, so any browsers can utilise it without much effort. At the moment, there are 18 different fonts (as of this post) that you can choose from and I am sure more will be added to the library in the future.

Previewing the font

In addition to the Google Font, Google also released the Google Font previewer that allows you to preview the font before embedding it to your site.

google-font-previewer

The usage is simple. You just have to type in some custom text, play around with the settings (font family, size, variants, spacing etc) to find the best fit for your site.

google-font-preview-example

Once you are satisfied with the result, simply grab the code and embed it into your site design.

google-font-code

Embedding Google Font to your WordPress site

If you are using a WP-powered blog, here’s how you can embed and use Google font in your site.

Go to Google Font, find your favorite font and grab the “Embed” code. For example:

Open up the “header.php” file in your active theme folder. Insert the code before the tag.

google-font-before-head-tag

To use the Google Font throughout the site, open your “style.css” file from the active theme folder and paste the remaining code that you grabbed from the Google Font site.

body {
  font-family: 'Cantarell', serif;
  font-size: 28px;
  font-style: normal;
  font-weight: 400;
  text-shadow: none;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0em;
  word-spacing: 0em;
  line-height: 1em;
}

Alternatively, you can change the css accordingly if you are only using it for a small part of your site. For example

span.custom_font {
  font-family: 'Cantarell', serif;
  font-size: 28px;
  font-style: normal;
  font-weight: 400;
}

Save the header.php and style.css file and upload them back to your server. If you are using a cache plugin, don’t forget to clear your cache.

That’s it. Try it out and let us know if it works for you.

Image credit: til01

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Damien Oh Avatar

Read next

Content and cloud networks now account for three-quarters of used international bandwidth, while Google, Meta, Microsoft and Amazon own, co-own or buy capacity on a growing share of the 600-plus submarine cable systems carrying over 99 per cent of data between countries, a private map hidden below the wireless internet
Wi-Fi doesn’t actually slow down when a café gets crowded — the signal is fine, but every device has to wait its turn to speak on the same frequency, and the polite queuing is what you feel as lag
In 1988, a 23-year-old Cornell graduate student named Robert Morris released a self-replicating program to measure the size of the internet — within hours it had crashed roughly 6,000 of the 60,000 machines then online, and computer security became a field
In July 2026, Psy’s Gangnam Style passed six billion YouTube views, fourteen years after its horse-riding dance became the platform’s first billion-view video and long after engineers had replaced a counter designed to stop at 2,147,483,647
Suzanne Simard sealed paper birch and Douglas fir seedlings inside plastic bags, fed them carbon-14 and carbon-13 dioxide, and nine days later found carbon had crossed between species through fungal threads in the British Columbia soil beneath her boots
A species of jellyfish called Turritopsis dohrnii can revert its adult cells back to a juvenile polyp stage when injured or starving, effectively restarting its life cycle, and biologists have so far failed to identify any natural limit to how many times it can do this.
A Japanese man named Jiroemon Kimura, who lived to 116, was born in 1897 when Queen Victoria still ruled and died in 2013, meaning a single human life personally overlapped with the invention of the airplane, the atomic bomb, the internet, and Instagram
The Hollywood sign originally read HOLLYWOODLAND when it was built in 1923 as a real estate advertisement for a housing development, and it was only meant to stand for 18 months, but nobody ever got around to taking it down and the city eventually adopted it as a landmark