This is an important message requiring you to make a choice if you're based in the EU.

CSS font-family Property

The font-family property allows to create a prioritized list of font family names and/or generic family names for the selected element.

We use commas to separate the values and show them as alternatives. The browser will select the first font to use if it is available. However, it may be unavailable in some cases like the user's computer doesn't have that font. When this situation occurs, the browser will try to use the next alternative to show the texts (or even a character which the first font cannot show).

There are two types of font family names:

  1. family-name: It is the name of a font-family such as "times", "courier", "arial", etc.
  1. generic-family:It is the name of a generic-family such as "serif", "sans-serif", "cursive", "fantasy", "monospace".

When the font name has whitespace, it must be enclosed in quotation marks as follows: "Courier New".

When we want to use unique font-family, we need to use @font-face property.

Initial Value Depends on the browser.
Applies to All elements. It also applies to ::first-letter and ::first-line.
Inherited Yes.
Animatable No.
Version CSS1
DOM Syntax object.style.fontFamily = "Verdana,sans-serif";


font-family: family-name | generic-family | initial | inherit;


<!DOCTYPE html>
    <title>Title of the document</title>
      p {
      font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; 
    <h2>Font-family property example</h2>
    <p>We used "Lucida Grande" font-family for this text.</p>


Value Description
family-name generic-family Prioritized list of font family names and/or generic family names.
initial Makes the property use its default value.
inherit Inherits the property from its parents element.

Browser support

1.0+ 12.0+ 1.0+ 1.0+ 3.5+

Practice Your Knowledge

What is the correct CSS syntax to change the font name?

Do you find this helpful?

Related articles