🚨 Get Your Free NFT Certificate Mint by Completing the Web3 Exam! START NOW

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.

DataCamp
Pros
  • Easy to use with a learn-by-doing approach
  • Offers quality content
  • Gamified in-browser coding experience
  • The price matches the quality
  • Suitable for learners ranging from beginner to advanced
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable
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
Udemy
Pros
  • Easy to navigate
  • No technical issues
  • Seems to care about its users
Main Features
  • Huge variety of courses
  • 30-day refund policy
  • Free certificates of completion

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+