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.

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

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+

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 18/01/2021
3176 People Used
Only 97 Left
Rating
5.0