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

CSS font-family property

CSS font-family property

Example

Specify the font of a paragraph:

p

{

font-family:

"

Times

New

Roman

",

Georgia

,

Serif

;

}

Try it »


Property definition and usage

The font - family property specifies the font of 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:

Using a specific font family (Geneva) depends entirely on whether that family is available on the user's machine; this property does not indicate any font download. Therefore, it is strongly recommended to use a generic font family name as a fallback.

Note: Separate each value with a comma.

**Note: ** If a font name contains spaces, it must be enclosed in quotes. 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 indicate the first browser version that supports this property.

property
font-family 1.0 4.0 1.0 1.0 3.5

Attribute values

Value Description
  • family-name
  • 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