How to Use CSS to Customize Fonts in a WordPress Theme

Start

You can change the fonts in your WordPress theme for style or readability purposes. Typographic (or font) design experts use simple font variations to achieve amazing design results. You can use fonts to separate headlines from body text (or widget headlines and text from the main content) to be less distracting.

Font family

The web is actually kind of picky about how it displays fonts, as well as what kind of fonts you can use in the font-family property. Not all fonts appear correctly on the web. To be safe, here are some commonly used font families that appear correctly in most browsers:

  • Serif fonts: Times New Roman, Georgia, Garamond, and Bookman Old Style

  • Sans-serif fonts: Verdana, Arial, Tahoma, and Trebuchet MS

When you want to change a font family in your CSS, open the stylesheet (style.css), search for property: font-family, change the values for that property, and save your changes.

In the default template CSS, the font is defined in the <body> tag like this:

font-family: Georgia, "Bitstream Charter", serif;

Font color

With more than 16 million HTML color combinations available, you can find just the right shade of color for your project. After some time, you’ll memorize your favorite color codes. Knowing codes for different shades of gray helps you quickly add an extra design touch.

You can easily change the color of your font by changing the color property of the CSS selector you want to tweak. You can use hex codes to define the colors.

You can define the overall font color in your site by defining it in the body CSS selector like this:

body {
color: #333;
}

Font size

To tweak the size of your font, change the font-size property of the CSS selector you want to adjust. Font sizes are generally determined by units of measurement, as in these examples:

  • px: Pixel measurement, or px; increasing or decreasing the number of pixels increases or decreases the font size (12px is larger than 10px).

  • pt: Point measurement, or pt; as with pixels, increasing or decreasing the number of points affects the font size accordingly (12pt is larger than 10pt).

  • %: Percentage measurement, or %; increasing or decreasing the percentage number affects the font size accordingly (50% is equivalent to 8 pixels; 100% is equivalent to 16 pixels).

In the default template CSS, the font size is defined in the body tag in pixels, like this:

font-size: 12px;

Put it all together

Style the font for the overall body of your site by putting all three elements (font-family, color, and font-size) together in the <body> tag. Here’s how they work together in the <body> tag of the default template CSS:

body {
font-size: 12px;
font-family: Georgia, "Bitstream Charter", serif;
color: #666;
}

Gurminder

Gurminder is a political scientist and critical thinker based in Australia. He regularly blogs on constructive criticism.