Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style fontFamily Property

Style fontFamily Property

Style Object Reference 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:

**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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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:

Runoob Tutorial(runoob.com)

This is some text.


Try it »


Style Object Reference The Style object