CSS2 » Properties » font-family

Version: Level 1

Compability: IE4+  N4+

Syntax:
font-family : family-name &| generic-family
generic-family
There are five values of generic-name typefaces to choose from:
cursive
fantasy
monospace
serif
sans-serif
 
It is recommended that generic-name typeface values be used as a last resort.
 
family-name
The family-name typeface values are the font names, such as: Courier, Arial, Times, Roman, etc. It is not possible to present a definitive list since not all computers have all typefaces installed.

The font-family property allows you to select specific typefaces or a generic family of typefaces. This property is inherited.

You can list a prioritized selection of family-name and/or generic-name typefaces. The program will consider each typeface value in turn and will use the first value it finds that is recognized by the browser. In the list, each typeface value must be separated by a comma. This is one of the few places where commas are used in declaring values for a property. The use of a pair of double quotes to enclose the typeface name is optional. However, it is recommended that any typeface name, such as "helvetica extra bold", that contains blank (white) spaces, should be enclosed by double quotes. Note that single quotes must be used in place of double quotes when using certain HTML code.

Examples

Code:
p { font-family: Courier, "Zapf Dingbat", serif}
Language(s): CSS2
Code:
<span style="font-family: arial;">Arial </span>
<span style="font-family: courier;">Courier </span>
<span style="font-family: helvetica;">Helvetica </span>
<span style="font-family: palatino;">Palatino </span>
<span style="font-family: symbol;">Symbol </span>
<span style="font-family: times;">Times </span>
Output:
Arial Courier Helvetica Palatino Symbol Times
Language(s): CSS2

See Also: