🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS Font Family

Define the typography of your web pages. Learn about generic families, stacks, and fallback mechanisms.

style.css
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
h1 {
font-family: "Georgia", serif;
}

Serif Heading

This is a paragraph in Sans-Serif font.

font-family.css
1 / 8
🅰️

Tutor:The font-family property specifies the font for an element. It's the core of web typography.


Typography Mastery

Unlock nodes by learning font families and stacks.

Concept 1: Generic Families

CSS defines five generic font families: serif, sans-serif, monospace, cursive, and fantasy. These are keywords, not specific font names.

System Check

Which generic family typically has small lines at the ends of characters?


Community Type Foundry

Share Font Stacks

Found a perfect combination of fonts? Share your stack code.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS Font Family

Author

Pascual Vila

Frontend Instructor.

The font-family property allows you to specify the typeface for selected elements. It is one of the most fundamental properties in web design, as it dictates the visual tone of your text.

Generic Families

Generic families act as a fallback mechanism. If specific fonts are not available, the browser chooses a default font from the specified generic category.

  • Serif: Fonts with small lines or strokes at the ends of characters (e.g., Times New Roman, Georgia).
  • Sans-serif: Fonts without these lines, often cleaner and modern (e.g., Arial, Helvetica).
  • Monospace: Fonts where every character has the same width (e.g., Courier New).
  • Cursive: Fonts that imitate handwriting.
  • Fantasy: Decorative fonts.

The "Stack"

You should always provide a "stack" of fonts. The browser checks them in order. If the first isn't installed on the user's device, it checks the second, and so on.

font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;

Always end your stack with a generic family name to ensure the browser picks something appropriate if all else fails.

Quotes

If a font name contains whitespace, it must be quoted. For example: "Times New Roman" or "Courier New". Single-word names like Arial do not need quotes.

Typography Glossary

Font Family
A group of fonts that share a similar design. In CSS, it sets the priority list of fonts to be used.
Serif
A typeface style characterized by small lines or strokes attached to the end of a larger stroke in a letter or symbol.
Sans-Serif
"Sans" means "without". These fonts lack the decorative strokes at the ends of characters.
Font Stack
A list of fonts declared in the `font-family` property. The browser uses the first available font in the list.
Web Safe Fonts
Fonts that are pre-installed on the majority of operating systems (e.g., Arial, Times New Roman).