← All languages
CSS construct of the day
Random

font-family

Specifies the font for an element's text content.

Description

The font-family property specifies a prioritized list of font family names and/or generic family names for the text content of an element. The browser uses the first font in the list that is available on the user's system or has been loaded via @font-face.

Font family names containing spaces must be quoted (e.g., 'Times New Roman'). Generic family names like serif, sans-serif, monospace, cursive, and fantasy should not be quoted and should always be included as a fallback.

A well-chosen font stack ensures consistent typography across different operating systems and browsers. It is best practice to end the list with a generic family name.

Arguments

NameDescriptionOptional
family-name One or more font family names separated by commas, ending with a generic family (e.g., sans-serif, serif, monospace). No

Example

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
code {
  font-family: 'Fira Code', 'Courier New', monospace;
}

Reference