CSS font-family Property
Description
The font-family property controls which typeface(s) the user agent will use to render text by providing a prioritized list of font family names and generic family identifiers. The browser examines that list in order and selects the first face that is available on the system or provided by a web font; if none match, it falls back to a generic family so text remains readable. Because different fonts have different metrics and glyph coverage, the choice of family affects not only the visual style (serif vs sans-serif, display vs text, monospaced vs proportional) but also line breaks, wrapping, and how much text fits on a line.
When a preferred family is not present, substitutes are chosen according to name matching and the fonts the platform exposes; substitution can change metrics such as x-height, letter widths and kerning, which may trigger layout shifts and reflow. Web fonts introduce additional timing considerations: while a remote font is loading the UA may temporarily render text with a fallback and then swap in the web font (or hide text briefly), so authors often design their family stack to minimize jarring changes by pairing fonts with similar proportions and by including a sensible generic family at the end of the list.
font is commonly used in concert with font-weight, font-style and font-size to achieve the intended typographic result; for example, weight and style selectors narrow which face within a family the renderer should attempt to use. Because type choices alter vertical rhythm, authors also consider line-height when switching families so that spacing and readability remain consistent across different faces and screen sizes. Best practice is to include a short, prioritized list of reliable fonts and end with a generic family, choose families that are metrically compatible when possible, and test pages across platforms to observe substitutions and layout impacts.
Definition
- Initial value
- Depends on user agent
- Applies to
- All elements
- Inherited
- Yes
- Computed value
- As specified
- Animatable
- No
- JavaScript syntax
- object.style.fontFamily
Interactive Demo
Syntax
font-family: [ <family-name> | <generic-family> ] #
Values
- <family-name>The name of a font family of choice such as Helvetica or Verdana. You can reference fonts available on the users system, or external fonts imported using @font-face. When the font name contains more than one word, it should be enclosed in quotes, for example "Times New Roman".
- <generic-family>The following generic family keywords are defined: 'serif', 'sans-serif', 'cursive', 'fantasy', and 'monospace'. These keywords can be used as a general fallback mechanism when an author's desired font choices are not available. As keywords, they must not be quoted. Authors are encouraged to append a generic font family as a last alternative for improved robustness.
- inherit
Example
Browser Support
The following information will show you the current browser support for the CSS font-family property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
