Open In App

CSS font-family Property

The font-family property specifies the font of an element. It can have multiple fonts as a backup system i.e. if the browser doesn’t support one font then the other can be used. In other words, this property is used to specifies the family-name &/or generic-family, based on the priority from the list, for the selected element.

The font-family can be categorized into 2 types:



Syntax: 

element_selector {
    font-family: family-name|generic-family|initial|inherit;
} 

Property values:



Note: The font-name can be declared with the single quotes when using the style attribute in the HTML & also it must be quoted when it contains white space.

We will understand the usage of the font-family property by implementing it.

Example: This example illustrates the use of the font-family property.




<!DOCTYPE html>
<html>
<head>
    <title> CSS | font-family Property </title>
    <style>
    .para1 {
        font-family: "Impact", Times, serif;
    }
      
    .para2 {
        font-family: Arial, Helvetica, sans-serif;
    }
    </style>
</head>
  
<body>
    <h1>Font-family Property</h1>
    <p class="para1">GeeksforGeeks in Impact font</p>
  
    <p class="para2">GeeksforGeeks in Arial font.</p>
  
</body>
</html>

Output:

Supported Browsers: The browsers that support the font-family property, are listed below:

Article Tags :