Watching:

Change Font Family Styles in WordPress


show more Changing font family styles provides you with in-depth training on Web. Taught by Morten Rand-Hendriksen as part of the WordPress 3: Building Child Themes show less
please wait ...

Changing font family styles

A website is a representation of individuality. Whether it be your own or that of your company. One of the many factors that play into putting forward a consistent presence on the web is the use of fonts. In the past, web fonts were fairly restricted. But today thanks to modern browser technology, you have far greater options where fonts are concerned. The Twenty Twelve theme ships with a custom font hosted by Google Web fonts. Later in the course, we will look at how you can swap out this Google font for different Google web font, but for now, let's take a look at how you can change the style sheet in your child theme to use a standard font instead of the one that ships.

Looking at the Twenty Twelve theme, you can see it uses a Sans Serif font, and if we go behind the scenes to look at the style-sheets. So I'll go in here and go Inspect elements, to any elements, and go to Computed Style, you'll see down here under font family, the font that's being used is called Open Sans. It also as a fallback to Helvetica, Arial, and Sans Serif. This is what's called the font family. What happens here is the browser will try to use Open Sans, if Open Sans doesn't work, it'll use Helvetica. If Helvetica doesn't work, it'll use Arial and if Arial doesn't work it'll use any Sans Serif font.

What we want to do is make it change to this font family in such a way that we can use different fonts. To find the original style that kicks in here, instead of using the technique I showed you earlier, I'm simply going to go into the Computed Styles and click on this link that points to the original style in the style-sheet. It's right here. You see body.custom-font-enabled and then you have the font family: Open Sans, Helvetica, Arial, Sans Serif. Directly above it, you'll notice that the body style also has a font family defined.

This is because Twenty Twelve comes with two options, you can use a custom style, custom font enabled, or you can disable the custom font using code and then the original styles will kick in. Right now, we're going to make a change to the body.custom-font-enabled style. So I'll copy that's style out, go in to my child theme, and because this is a body style it should be high up in the hierarchy. So I'm going to paste that in directly under the import call. So here we have the original style the way it was, but now I want to change to font family over completely to another standard font family.

So I'm going to swap out all this code with Georgia, Times New Roman, Times, Serif. When I save the style-sheet now, and reload the web page in my browser, you will see that all the fonts on the entire page have been changed to Georgia because that's now the main font family. Now it's important to note that this doesn't necessarily work the exact same way on all themes. Many themes have very specific fonts assigned to different elements, and you may find that there's several different places where the font is defined.

In which case, you have to go in and find all the places where the font is defined in the original style-sheet and then overwrite it piece by piece, but in a well-written theme the font is defined once at the very top and you can simply overwrite it the way we did just know, by just typing in a new font family. Changing the font family of a website can make a huge difference in how the website appears in what message it communicates to the visitor. Choosing the right font family for your site is important, and no matter what people say, there is no such thing as a right or wrong font.

The font that fits with your message and communicates it well is the right font for your website.

Changing font family styles
Video duration: 3m 38s 3h 11m Intermediate Updated Nov 27, 2012

Viewers:

Changing font family styles provides you with in-depth training on Web. Taught by Morten Rand-Hendriksen as part of the WordPress 3: Building Child Themes

Subject:
Web
Software:
WordPress
Author:
please wait ...