Style fontFamily Property
The Style object
Definition and Usage
The fontFamily property sets or returns a list of font family names and/or generic family names for the text in an element.
The browser uses the first value it can recognize.
There are two types of font family values:
- font-family: a font family name, such as "verdana" or "arial".
- generic-family: a generic family name, such as "serif" or "sans-serif".
**Tip:** Always specify a generic family name as the last choice!
**Note:** If a font family name contains spaces, enclose it in quotes.
**Tip:** SeeWeb safe fontsCommon font combinations.
Syntax
Sets the fontFamily property:
Object.style.fontFamily="
font1, font2, etc.
|inherit"
Returns the fontFamily property:
Object.style.fontFamily
| Value | Description |
|---|---|
| font1, font2, etc. | A list of font family names and/or generic family names, separated by commas. |
| inherit | The fontFamily property value is inherited from the parent element. |
Browser support





All major browsers support the fontFamily property.
**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".
Example
Example
Changes the font of the text:
This is some text.
Try it »
The Style object