- WordPress 2.7 Cookbook
- Jean-Baptiste Jung
- 511字
- 2021-04-01 13:55:49
Modifying your theme fonts
Now that you have learned how to search and replace hexadecimal color codes, let's customize your theme a bit more.
In this recipe, we're going to see how we can easily modify the fonts used in a WordPress theme and also discuss about the good practices for typography on a WordPress blog.
Getting ready
For this recipe, you'll need exactly the same things that were needed in the Modifying your theme colors recipe—a theme to customize, and a text editor.
A common beginner mistake is to try and use non web-safe fonts on a web site or blog. For example, there are web sites using the Myriad Pro or Segoe UI fonts. These fonts look beautiful, but what if only 10 or less percent of your readers can render it?
The following web-safe fonts can be used on any web sites:
- Times New Roman
- Arial
- Verdana
- Courier
- Comic
Installed on more than 80% of computers, these two fonts can be used as well:
- Trebuchet MS
- Century Gothic
How to do it...
Most WordPress themes use a maximum of three different fonts. However, it is common to only use one or two different fonts. There's not a big choice, in terms of fonts, due to the fact that a user must have the font installed on his computer to have it render correctly on a web site.
- In order to modify the fonts of a theme, the first step is to find out which are the fonts used. To do so, open the
style.css
file, in Vi and use thesearch
command to find the font and font-family CSS properties:/font
- This command will find all the occurrences of font in the stylesheet. To go to the next occurrence, simply type
n
. - The font-family CSS property looks as follows:
font-family: "Trebuchet MS", arial, serif;
- This CSS property allows you to specify one or more fonts to be used. In our example, if in case Trebuchet MS isn't available on the client computer, Arial will be used.
- The font CSS property is a shorthand which allows you to specify all the font related parameters on a single line:
font: italic small-caps bold 12px arial;
- To modify the size of a font, you'll look for the
font-size
CSS property.
There's more...
It can be very tempting to play with the fonts and CSS fonts related properties. However, there are a few things to be kept in mind:
- The standard font size of a text is between 11 and 14 pixels; 12px is the most common choice of font size. For titles, (
h1
,h2
,h3
, and so on) a font size between 14 and 26 pixels is good. - While using a font with a two word name (for example,
Trebuchet MS
), always put it between quotes; that is,font-family: "Trebuchet MS"
;) - While defining font families always list at least two fonts, and offer a generic family name as the last alternative. The client's browser will use the first font that it recognizes.
- Photoshop圖形圖像設(shè)計(jì)案例教程(高等院校計(jì)算機(jī)任務(wù)驅(qū)動(dòng)教改教材)
- Photoshop CC超級(jí)學(xué)習(xí)手冊(cè)
- UI 設(shè)計(jì)入門(mén)一本就夠
- 中文版 Photoshop CC 從入門(mén)到精通
- 板繪教室:SAI零基礎(chǔ)日系動(dòng)漫插畫(huà)入門(mén)教程
- Drupal 6 Panels Cookbook
- 中文版Photoshop CC2018從入門(mén)到精通(第4版)
- Microsoft Silverlight 5: Building Rich Enterprise Dashboards
- OpenCart 1.4 Template Design Cookbook
- 陌上花開(kāi):古風(fēng)CG插畫(huà)繪制技法精解(花卉篇)
- UG NX 8.0模具設(shè)計(jì)教程
- Excel 2013公式·函數(shù)與數(shù)據(jù)分析
- Excel革命!超級(jí)數(shù)據(jù)透視表Power Pivot與數(shù)據(jù)分析表達(dá)式DAX快速入門(mén)
- Joomla! E/Commerce with VirtueMart
- FLUENT 15.0流場(chǎng)分析實(shí)戰(zhàn)指南