liveBook · Manning

Generic font

As explained in Web Design Playground

A fallback font category name in CSS that lets the browser choose an available font of a general type such as serif or sans-serif.

A generic font is a broad font-family name such as serif or sans-serif. Think of it as asking for a kind of outfit rather than one particular shirt: the browser picks an available font that fits the category. section 4.3

CSS provides five generic font families:

Use a generic family directly when you want a broad type style. For example, headings can use sans-serif while paragraphs use serif through the font-family property. section 4.3

A fallback for a named font

Put a generic font after a specific font name. The browser uses Lato for paragraph text when it loads; otherwise, sans-serif gives it a sensible backup style. section 18.6

p {
    font-family: Lato, sans-serif;
}

This rule places the named Lato font first and the generic sans-serif family second, so the latter can display if the third-party font file fails to load. section 18.6

The same fallback idea is useful with hosted or self-hosted fonts: a generic font name keeps text styled even when a chosen font is unavailable. section 18.9 section 18.6

How Web Design Playground covers it

How deep it goes
Defines five generic families and demonstrates applying them with font-family, including a named-font fallback.
Examples
Uses sans-serif for an h3, serif for a p, and Lato with sans-serif for paragraph text.
What you can do after
Apply it via the font-family property as a direct type category or named-font fallback.
How it connects
Connects font-family to serif, sans-serif, monospace, cursive, fantasy, Google Fonts, and @font-face.

Also explained in

Compare how 2 books explain generic font →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.