CSS font-family
The CSS font-family
property specifies the font family of text content. It allows you to specify a prioritized list of font family names or generic family names for the browser to use when displaying text.
The font-family
property should be applied to the elements you want to style the text for, such as headings, paragraphs, or individual span
elements.
Let's take a look at an example:
In the example above, we have specified different font families for each paragraph using the font-family
property. The browser will attempt to use the first font family in the list, and if it is not available, it will move on to the next font family in the list.
You can also specify generic font family names as fallback options in case a specific font family is not available on the user's system. The generic family names are serif
, sans-serif
, monospace
, cursive
, and fantasy
.
It is important to note that not all font families are available on all systems, so it is a good practice to provide a fallback font family or use generic font families to ensure that your text content is displayed correctly across different devices and browsers.