Property Description
The font-family property sets the font for an element.
This property has the following syntax:
font-family: family-name|generic-family|initial|inherit;
The font-family property can use several font names as a "fallback" system. If the browser does not support the first specified font, it tries the next specified font.
There are two types of font family names:
- family-name - The name of a font-family, like "times", "courier", "arial", etc.
- generic-family - The name of a generic-family, like "serif", "sans-serif", "cursive", "fantasy", "monospace".
Note: Separate each font value with a comma.
Note: If a font name contains white-space, it must be quoted. Single quotes must be used when using the "style" attribute in HTML.
Property Values
Value | Description |
---|---|
family-name generic-family |
A list of font family names and/or generic family names. |
initial | Specifies that the value of the property should be set to the default value |
inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example specifies the font for a paragraph.
p.sansserif {
font-family:Arial,Helvetica,sans-serif;
}
p.serif {
font-family:"Times New Roman",Times,serif;
}
<p class="sansserif">This is the Arial font.</p>
<p class="serif">This is the Times New Roman font.</p>
This produces the following result:
This is the Arial font.
This is the Times New Roman font.
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
1.0 | 1.0 | 5.5 | 1.0 | 7.0 |
Miscellaneous Information
Inherited: | Yes |
---|---|
Defined In: | CSS1 |
Default Value: | depends on the browser |