The font-family property sets the typeface for text using a prioritized font stack. It is one of the most important properties for readable, on-brand web typography.
01
Font stack
Comma list.
02
Fallbacks
First match wins.
03
Generic
serif, sans-serif.
04
Quotes
Multi-word names.
05
Web fonts
@font-face.
06
Inherited
From parent.
Fundamentals
Introduction
The font-family property in CSS is used to specify the typeface of text. It allows web developers to define a prioritized list of font family names and/or generic family names for the selected element.
Definition and Usage
This property plays a crucial role in controlling the typography of a web page, ensuring that text is rendered in a visually appealing and readable manner. List fonts from most preferred to most fallback, and end with a generic family like sans-serif or serif whenever possible.
💡
Beginner Tip
Think of font-family as a backup plan. The browser tries each font left to right until it finds one installed on the device or loaded via a web font.
Foundation
📝 Syntax
The syntax for the font-family property involves listing one or more font family names, separated by commas. Generic family names should always be included as a fallback:
syntax.css
element{font-family:"font-name",generic-family;}
Here, "font-name" can be a specific font family, and generic-family is one of the five generic font families: serif, sans-serif, monospace, cursive, or fantasy.
The default value of the font-family property depends on the user agent (browser). Typically, it is set to the browser's default sans-serif font.
Syntax Rules
Separate multiple font names with commas, most preferred first.
Quote names that contain spaces: "Times New Roman".
Always include a generic family as the final fallback when possible.
The property is inherited — set it on body for site-wide typography.
Font names are case-sensitive on some systems; match official spelling.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
Browser-dependent (usually a sans-serif UI font)
Applies to
All elements
Inherited
Yes
Value type
Comma-separated list of font family names
Common pattern
font-family: "Segoe UI", system-ui, sans-serif;
Reference
💎 Property Values
Specific font family names
Named typefaces installed on the user's device or loaded as web fonts, such as Arial, Times New Roman, and Courier New.
Generic family names
Generic family
Description
serif
Fonts with small strokes at letter ends, such as Times-style typefaces.
sans-serif
Fonts without those strokes, such as Arial-style typefaces.
monospace
Fonts where every character has the same width, ideal for code.
cursive
Fonts that emulate handwriting.
fantasy
Decorative display fonts that do not fit other categories.
System UI keywords
Modern stacks often include system-ui or ui-sans-serif so text matches the operating system interface font before falling back to generic families.
Context
Common Font Stacks
Stack
Best for
system-ui, sans-serif
Clean UI text that matches the OS
Georgia, "Times New Roman", serif
Articles, long-form reading
"Segoe UI", Roboto, Arial, sans-serif
Cross-platform body copy
ui-monospace, "Cascadia Code", monospace
Code blocks and terminals
Preview
👀 Live Preview
The same sentence in sans-serif, serif, and monospace stacks:
Arial, sans-serifThe quick brown fox jumps over the lazy dog.
Georgia, serifThe quick brown fox jumps over the lazy dog.
"Courier New", monospaceThe quick brown fox jumps over the lazy dog.
Hands-On
Examples Gallery
In this example, we set the font family of a paragraph to Arial with a sans-serif fallback — plus serif stacks, monospace code, and a web font with @font-face.
🔠 Font Stacks
Start with the reference example — a named font with a generic fallback.
Example 1 — Arial with sans-serif Fallback
Set paragraph text to Arial. If Arial is unavailable, the browser uses any sans-serif font.
font-family-arial.html
<style>p{font-family:"Arial",sans-serif;}</style><p>
This paragraph uses Arial. If Arial is not available, it falls back to a sans-serif font.
</p>
If the custom file fails to load, system-ui and sans-serif keep the heading readable.
How It Works
@font-face registers a downloadable font. Your stack still needs fallbacks in case the file is blocked or slow to load.
A11y
♿ Accessibility
Choose readable typefaces for body text; avoid decorative fonts for long paragraphs.
Provide fallbacks so text remains legible if a custom font fails to load.
Do not use font choice alone to convey meaning or status.
Test loaded web fonts for clarity at small sizes and high zoom levels.
Respect user font settings by using relative sizes and sensible system fallbacks.
🧠 How font-family Works
1
You define a font stack
List preferred fonts in order, ending with a generic family when possible.
Declaration
2
Browser checks availability
Each name is tested left to right — installed fonts and loaded web fonts qualify.
Matching
3
First match is used
If no named font matches, the generic family selects an appropriate system typeface.
Fallback
=
🔠
Rendered typography
Text displays in the best available font for the user's device and your design.
Compatibility
🖥 Browser Compatibility
The font-family property is universally supported across all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is one of the most fundamental CSS properties for web typography.
✓ Baseline · Universal support
font-family everywhere
Named fonts, generic families, and font stacks work in every browser, including legacy environments.
99%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
font-family property99% supported
Bottom line:font-family is essential and safe everywhere. Pair with web font loading strategies for custom brand typefaces.
Wrap Up
🎉 Conclusion
The font-family property is a key tool for web developers to control the typography of their web pages. By specifying a list of preferred fonts along with generic fallbacks, you can ensure that your text is rendered in a way that matches your design vision.
Experiment with different font families to see how they impact the look and feel of your web projects. Build thoughtful stacks, quote multi-word names, and always keep a readable fallback at the end of the list.
End stacks with a generic family like sans-serif or serif
Quote font names that contain spaces
Set base typography on body so children inherit it
Include system fonts like system-ui for native feel
Provide fallbacks when using custom web fonts
❌ Don’t
Rely on a single font name with no fallback
Use too many fonts on one page — it hurts consistency
Forget quotes on names like Times New Roman
Choose decorative fonts for long body paragraphs
Assume every user has the same fonts installed
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about font-family
Use these points when choosing typefaces for your site.
5
Core concepts
🔠01
Font stack
Comma-separated list.
Purpose
↦02
First match
Browser picks one.
Behavior
serif03
Generic families
Final fallback.
Values
"04
Quote names
Spaces need quotes.
Syntax
🔁05
Inherited
Set on body.
Cascade
❓ Frequently Asked Questions
The font-family property sets the typeface for text. You provide a prioritized list of font names; the browser uses the first available font in the list.
Generic families like sans-serif or serif act as a final fallback if none of your named fonts are installed. They help ensure text still renders in an appropriate style.
Quote font names that contain spaces, digits at the start, or special characters, such as Times New Roman. Single-word names like Arial usually work with or without quotes.
A font stack is the comma-separated list in font-family, ordered from most preferred to fallback options, ending with a generic family when possible.
font-family only chooses the typeface. The font shorthand can also set size, weight, style, and line-height in the same declaration.