It’s Festive Season! Enjoy 30% Off

Use code FESTIVE30 at checkout

Code has been added to clipboard!

The CSS Font-Family Property

Reading time 1 min
Published Sep 8, 2017
Updated Oct 10, 2019

How to use CSS font-family

The CSS font-family property defines what font an element will use when it contains text:

Example
p {
    font-family: "Arial Black", "Arial Bold", Gadget, sans-serif;
}

This property can also hold several values separated by commas as a fallback system. If one font is not available or not supported, then the following font specified by the property can be used.

Defining font families

The syntax for CSS font-family is as follows:

font-family: value;

There are two ways to specify a CSS font family: you can either define an exact embedded or downloaded font, or name one of five generic font families:

  • cursive
  • fantasy
  • monospace
  • serif
  • sans-serif

When listing multiple CSS font families, you should begin by specifying the font you'd prefer the most and finish by specifying a generic family as a fallback. Then, if no specified fonts are available, the browser will select a similar accessible font from the generic CSS font family.

Note: if the font name contains a space, it has to be surrounded by quotes.

Browser support

Browser image
Chrome
1+
Browser image
Edge
12+
Browser image
Firefox
1+
Browser image
IE
3+
Browser image
Opera
3.5+
Browser image
Safari
1+

Mobile browser support

Browser image
Chrome
18+
Browser image
Firefox
4+
Browser image
Opera
10.1+
Browser image
Safari
1+