font-family

The font-family CSS property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.

/* A font family name and a generic family name */
font-family: Gill Sans Extrabold, sans-serif;
font-family: "Goudy Bookletter 1911", sans-serif;
/* A generic family name only */
font-family: serif;
font-family: sans-serif;
font-family: monospace;
font-family: cursive;
font-family: fantasy;
font-family: system-ui;
/* Global values */
font-family: inherit;
font-family: initial;
font-family: unset;

Values are separated by commas to indicate that they are alternatives. The browser will select the first font in the list that is installed or that can be downloaded using an @font-face at-rule.

It is often convenient to use the shorthand property font to set font-size and other font related properties all at once.

Note: You should always include at least one generic family name in a font-family list, since there's no guarantee that any given font is available. This lets the browser select an acceptable fallback font when necessary.

Note: The font-family property specifies a list of fonts, from highest priority to lowest. Font selection does not simply stop at the first font in the list that is on the user's system. Rather, font selection is done one character at a time, so that if an available font does not have a glyph for a needed character, the latter fonts are tried. (However, this doesn't work in Internet Explorer 6 or earlier.) When a font is only available in some styles, variants, or sizes, those properties may also influence which font family is chosen.

Initial valuedepends on user agent
Applies toall elements. It also applies to ::first-letter and ::first-line.
Inheritedyes
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

The font-family property lists one or more font families, separated by commas. Each font family is specified as either a <family-name> or a <generic-name> value.

The example below lists two font families, the first with a <family-name> and the second with a <generic-name>:

font-family: Gill Sans Extrabold, sans-serif;

Values

<family-name>
The name of a font family. For example, "Times" and "Helvetica" are font families. Font family names containing whitespace should be quoted.
<generic-name>

Generic font families are a fallback mechanism, a means of preserving some of the style sheet author's intent when none of the specified fonts are available. Generic family names are keywords and must not be quoted. A generic font family should be the last item in the list of font family names. The following keywords are defined:

serif
Glyphs have finishing strokes, flared or tapering ends, or have actual serifed endings.
E.g. Lucida Bright, Lucida Fax, Palatino, "Palatino Linotype", Palladio, "URW Palladio", serif.
sans-serif
Glyphs have stroke endings that are plain.
E.g. "Open Sans", "Fira Sans", "Lucida Sans", "Lucida Sans Unicode", "Trebuchet MS", "Liberation Sans", "Nimbus Sans L", sans-serif.
monospace
All glyphs have the same fixed width.
E.g. "Fira Mono", "DejaVu Sans Mono", Menlo, Consolas, "Liberation Mono", Monaco, "Lucida Console", monospace.
cursive
Glyphs in cursive fonts generally have either joining strokes or other cursive characteristics beyond those of italic typefaces. The glyphs are partially or completely connected, and the result looks more like handwritten pen or brush writing than printed letterwork.
E.g. "Brush Script MT", "Brush Script Std", "Lucida Calligraphy", "Lucida Handwriting", "Apple Chancery", cursive.
fantasy
Fantasy fonts are primarily decorative fonts that contain playful representations of characters.
E.g. Papyrus, Herculanum, Party LET, Curlz MT, Harrington, fantasy.
system-ui
Glyphs are taken from the default user interface font on a given platform. Because typographic traditions vary widely across the world, this generic is provided for typefaces that don't map cleanly into the other generics.

Valid family names

Font family names must either be given quoted as strings, or unquoted as a sequence of one or more identifiers. This means that punctuation characters and digits at the start of each token must be escaped in unquoted font family names.

For example, the following declarations are valid:

font-family: Gill Sans Extrabold, sans-serif;
font-family: "Goudy Bookletter 1911", sans-serif;

The following declarations are invalid:

font-family: Goudy Bookletter 1911, sans-serif;
font-family: Red/Black, sans-serif;
font-family: "Lucida" Grande, sans-serif;
font-family: Ahem!, sans-serif;
font-family: test@foo, sans-serif;
font-family: #POUND, sans-serif;
font-family: Hawaii 5-0, sans-serif;

Formal syntax

[ <family-name> | <generic-family> ]#

where
<family-name> = <string> | <custom-ident>+
<generic-family> = serif | sans-serif | cursive | fantasy | monospace

Examples

Some common font families

.serif {
  font-family: Times, Times New Roman, Georgia, serif;
}
.sansserif {
  font-family: Verdana, Arial, Helvetica, sans-serif;
}
.monospace {
  font-family: Lucida Console, Courier, monospace;
}
.cursive {
  font-family: cursive;
}
.fantasy {
  font-family: fantasy;
}

Specifications

Specification Status Comment
CSS Fonts Module Level 4
The definition of 'extended generics' in that specification.
Editor's Draft Adds new generic font families, specifically: system-ui, emoji, math, and fangsong.
CSS Fonts Module Level 3
The definition of 'font-family' in that specification.
Candidate Recommendation No significant change
CSS Level 2 (Revision 1)
The definition of 'font-family' in that specification.
Recommendation No significant change
CSS Level 1
The definition of 'font-familiy' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1 (Yes) 1.0 (1.7 or earlier) 3.0 3.5 1.0
system-ui 56 No support No support [1] No support 43 ? [2]
Feature Android Webview Chrome for Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1 1 (Yes) 1.0 (1) 6.0 6 1.0
system-ui 56 56 No support ? No support 43 ? [2]

[1] system-ui is not yet implemented, see bug 1226042.
[2] system-ui is implemented in Safari (wkbug.com/151493), may ship soon.
The prefixed alias -apple-system is supported by Safari since MAC OS X 10.11 and iOS 9 and since Firefox 43 on MAC OS (bug 1201318).