CSS font-family
Property
Example
Specify the font for a paragraph:
p {
font-family:"Times New Roman",Georgia,Serif;
}
Property Definition and Usage
The font-family
property specifies the font for an element.
font-family
can store multiple font names as a "fallback" system. If the browser does not support the first font, it tries the next one.
There are two types of font family names:
family-name - The specified series name: the name of a specific font, such as "times", "courier", "arial".
generic-family - Common font series names, such as "serif", "sans-serif", "cursive", "fantasy", "monospace".
Using a specific font family (Geneva) entirely depends on whether the font family is available on the user's machine; this property does not indicate any font downloading. Therefore, it is strongly recommended to use a generic font family name as a fallback.
Note: Each value is separated by a comma.
Note: If the font name contains spaces, it must be quoted. When using the "style" attribute in HTML, single quotes must be used.
Default value: | not specified |
---|---|
Inherited: | yes |
--- | --- |
Version: | CSS1 |
--- | --- |
JavaScript syntax: | object.style.fontFamily="arial,sans-serif" |
--- | --- |
Browser Support
The numbers in the table specify the first browser version that supports the property.
Property | |||||
---|---|---|---|---|---|
font-family | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Property Values
Value | Description |
---|---|
family-name<br>generic-family | A prioritized list of font family names and/or generic family names for an element. Default value: depends on the browser. |
inherit | Specifies that the font family should be inherited from the parent element. |
Related Articles
CSS Tutorial: CSS Font
CSS Reference Manual: font Property