Font families and fallback
Definition and purpose
A font stack lists preferred families in order; the browser tries available faces and glyphs, then falls back. End a stack with a suitable generic family.
A fallback stack
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { font-family: Arial, sans-serif; } #b { font-family: Georgia, serif; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>The two elements request different families; actual faces depend on the device.
Syntax and mental model
font-family: "Example Sans", Arial, sans-serif; lists alternatives, not fonts to blend. Generic names are unquoted. Missing glyphs can trigger fallback within a single line; computed style reports the requested list, not the actual face for each glyph.
Code versus prose
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { font-family: sans-serif; } #b { font-family: monospace; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>A requests a sans-serif face; B requests a fixed-width family.
Common mistakes
Do not quote the generic keyword or assume a named font exists on every device. Check the rendered font and language coverage in developer tools.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Color mixing and relative colors, Aspect ratio and replaced elements. Next lesson: Font size, weight and style.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Font families and fallback — knowledge check
Five questions on font families and fallback.
Which order is a font stack tried in?
Which is a generic family keyword?
What if a glyph is missing?
What does computed font-family report?
Which is appropriate for code?