CSS font-familyProperty


Example

Specifies the font of a paragraph:

p { font-family:"Times New Roman",Georgia,Serif; }

Try it Yourself »

Property definition and usage instructions

The font-family property specifies the font of an element.

The font-family property can store multiple font names as a "fallback" system. If the browser does not support the first font, it will try the next one.

There are two types of font family names:

  • family-name- Specified series name: the name of the specific font, for example: "times", "courier", "arial".
  • generic-family- 通常Font familyName:For example:"serif"、"sans-serif"、"cursive"、"fantasy"、"monospace"。

Using a specific font family (Geneva) entirely depends on whether that font 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 the property.

Property
font-family 1.0 4.0 1.0 1.0 3.5

Property value

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

other extensions