XML technologies / CSS / Advanced websites with CSS / CSS property reference / font-family
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The property font-family describes the typeface used to display an HTML element’s content. As with the HTML tag font, you can specify a list of typefaces, which the browser checks in order for availability on the user’s system and displays accordingly.
If a typeface or a character to be displayed is not installed on the user’s system, the browser tries the next typeface in the list. Because fonts are accessed for each character individually, multilingual content can specify a different typeface for each language. Fonts listed first in the declaration always take precedence.
The list of typefaces should always end with a generic font name (see below), which the browser can use if none of the previously specified typefaces is available.
Inherited: yes
See also: font
Values
A comma-separated list of typefaces. Font names containing spaces are enclosed in quotation marks (for example "Times New Roman").
In addition to typeface names, a declaration should include one of the following generic font names, for which the browser uses its default or user-defined setting:
serif: The browser chooses a serif typeface.sans-serif: The browser chooses a sans-serif typeface.cursive: The browser chooses a cursive typeface.fantasy: The browser chooses a stylized typeface.monospace: The browser chooses a fixed-width typeface.
Because a browser can always find a font for these generic font names, they are useful only as the last entry in the font list.
Default value: browser-dependent
Compatibility
CSS version: 1
Works in all CSS-capable browsers, including Netscape 4, Internet Explorer 4 and Mozilla.
Example
The following style rule assigns body a list of common typefaces. The font category sans-serif appears at the end as the lowest common denominator:
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg