The CSS `font-family` property tells the browser which typeface to use for an element’s text. A typeface is the design of the letters; a font is that design at a particular size, weight, and style. You can start with a generic family, name a typeface installed on the visitor’s computer, or use a font loaded from a host. section 4.1 section 4.2 section 4.3 section 18.3
Five generic families give you a quick starting point:
- `serif` has small finishing strokes and can work well for larger headings; `sans-serif` has a cleaner look suited to body text. section 4.1
- `monospace` gives every character the same width, making it useful for code listings. section 4.1
- `cursive` resembles handwriting and suits short, playful touches; `fantasy` is for a special effect. section 4.1
Start with a generic family
`h3 { font-family: sans-serif; }` gives level-three headings a sans-serif typeface, while `p { font-family: serif; }` gives paragraphs a serif one. The selectors decide which elements change; the property decides their typeface. section 4.2
Want a particular system font? List alternatives separated by commas. The browser checks them in order and uses the first one installed on the visitor’s computer. Finish with a similar generic family as a fallback: `font-family: "Times New Roman", Georgia, serif;`. Quote names containing spaces, numbers, or punctuation other than a hyphen; capitalizing system-font names also makes the CSS easier to read. section 4.3
Choose typefaces for a whole page
`body { font-family: Optima, Calibri, sans-serif; }` applies the choice to page text. Optima may be available on a Mac but not a Windows PC, so Calibri and then the generic `sans-serif` provide alternatives. A clean sans-serif also keeps a short landing page’s text from competing with its message. section 10.3
A hosted font takes one extra step: load its provider’s CSS before your own styles, then name the family in a rule such as `p { font-family: Lato, sans-serif; }`. The generic fallback covers a font file that fails to load. Add only the font styles you need—extra fonts slow page loading. section 18.3


