|
Choosing a font for your display is among the most common of all formatting tasks, but it is also one of the trickiest. In order for the viewer of the document to see it in the font you chose, the desired font must first be installed on his or her computer. If that font is not available for the browser, the browser will substitute another similar style font.
Although the popularity of Windows machines have made it easier to pick fonts that most people will have on their machine, issues remain. Therefore, good forethought should go into your font decisions.
The font-family property is used to define the typeface of the element. It is a prioritized list of font "family" names and can be composed of specific fonts, generic font families, or both:
- You can include the specific names of a font you wish, like this:
para { font-family: Times New Roman }
- You can also include the names of generic font families, like this:
para { font-family: serif }
You will often want to use both specific and generic font family names in your list. Doing so enables the browser to try your preferred font choice first. If that choice is not available, it can continue down the list. Adding the appropriate generic name as a final entry ensures that at least the general style of the font will be used even if the desired typeface is unavailable. Suppose, for example, that you'd like to use the sans serif style Trebuchet MS font as your first choice for an address element, but you have a set of acceptable alternatives. Your rule would look something like this:
address { font-family: Trebuchet MS, Verdana, Tahoma, Arial, sans-serif }
|