The font property is a CSS shorthand that sets style, weight, size, line-height, and family in one declaration. It is a fast way to create consistent typography across your site.
01
Shorthand
Many in one.
02
Size + family
Required pair.
03
Line-height
Size/height.
04
Weight & style
bold, italic.
05
Fallbacks
Font stacks.
06
Longhand
Split when needed.
Fundamentals
Introduction
The font property in CSS is a shorthand property for setting various individual font-related properties in one declaration. These properties include font-style, font-variant, font-weight, font-size, line-height, and font-family.
Definition and Usage
By using the font property, you can quickly apply multiple font settings to an element, ensuring a consistent and cohesive typographic style across your website. Use it on body text, headings, buttons, and any element where you want to control how text looks with fewer lines of CSS.
💡
Beginner Tip
At minimum, every font declaration needs a size and a family: font: 16px Arial, sans-serif;. Add weight, style, and line-height when you need them.
Foundation
📝 Syntax
The syntax for the font property can vary depending on which values are specified. Optional components come first, followed by mandatory font-size and font-family values:
The default value of the font property depends on the browser and operating system settings. Typically, it resolves to the browser's default font style, weight, size, and family for normal text.
Syntax Rules
font-size and font-family are required in every valid shorthand declaration.
Write line-height immediately after font-size with a slash: 16px/1.5.
Order matters: style, variant, and weight must come before size.
Always include a generic family fallback such as sans-serif or serif.
The property is not inherited as a shorthand name, but its longhand components are inherited individually.
The font shorthand combines values from these individual properties:
Component
Description
font-style
Defines the style of the font. Common values: normal, italic, and oblique.
font-variant
Controls small-caps. Values: normal and small-caps.
font-weight
Specifies font weight. Values include normal, bold, and numbers 100 through 900.
font-size
Sets text size in units like px, em, rem, or %. Required in the shorthand.
line-height
Sets line box height. Written after font-size with a slash, e.g. 16px/1.5.
font-family
Specifies the typeface stack. Required in the shorthand. Include generic families like serif or sans-serif.
System font keywords
CSS also allows system keywords such as caption, icon, menu, message-box, small-caption, and status-bar. These map to platform UI fonts and can be used alone: font: menu;
Context
Common font Shorthand Patterns
font declaration
What it sets
Typical use
font: 1rem/1.6 system-ui, sans-serif;
Size, line-height, family
Body copy, articles
font: bold 1.5rem Georgia, serif;
Weight, size, family
Section headings
font: italic 14px/1.4 Arial, sans-serif;
Style, size, line-height, family
Quotes, captions
font: inherit;
All font values from parent
Buttons, inputs
Preview
👀 Live Preview
Text styled with font: italic small-caps bold 1rem/1.55 Arial, sans-serif; from the reference example:
This paragraph uses the font property to apply multiple font settings in one declaration.
Hands-On
Examples Gallery
In this example, we use the font property to set various font characteristics for a paragraph — plus simple body text, bold headings, and inherited button fonts.
📝 Typography Basics
Start with the reference example — multiple font settings in one declaration.
Example 1 — Full Font Shorthand
Set style, variant, weight, size, line-height, and family together on a paragraph.
font-full.html
<style>p{font:italic small-caps bold 16px/1.5 Arial, sans-serif;}</style><p>
This paragraph uses the font property to apply multiple font settings in one declaration.
</p>
This paragraph uses the font property to apply multiple font settings in one declaration.
How It Works
Each part maps to a longhand property. The browser parses them in order and applies italic style, small caps, bold weight, 16px size, 1.5 line-height, and Arial with a sans-serif fallback.
Example 2 — Readable Body Text
A practical pattern for article content using rem units and comfortable line-height.
The button copies the parent's computed font values, keeping typography consistent in forms and toolbars.
A11y
♿ Accessibility
Use readable font sizes — body text is often 16px (1rem) or larger for comfortable reading.
Keep sufficient line-height — values around 1.5 to 1.7 improve readability for long paragraphs.
Do not rely on weight or style alone to convey meaning; use semantic HTML too.
Test custom fonts for legibility and ensure fallback stacks are defined.
Respect user zoom by preferring relative units like rem and em.
🧠 How font Works
1
You write one shorthand
List optional style, variant, and weight, then required size (and optional line-height), then family.
Declaration
2
Browser expands to longhand
The shorthand sets individual properties like font-size and font-family behind the scenes.
Parsing
3
Font stack resolves
The browser picks the first available font in the family list, falling back to generic families if needed.
Rendering
=
📝
Consistent typography
Text renders with your chosen style, size, spacing, and typeface in one concise rule.
Compatibility
🖥 Browser Compatibility
The font property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is a versatile shorthand that works well across different platforms.
✓ Baseline · Universal support
font shorthand everywhere
Size, line-height slash syntax, weight, style, and family stacks all work consistently in modern browsers.
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 property99% supported
Bottom line:font is safe for all modern projects. Split into longhand properties when you need to override only one value later.
Wrap Up
🎉 Conclusion
The font property in CSS is an efficient way to manage multiple font-related styles in a single declaration. By understanding and using this property, you can easily control the appearance of text on your web pages, ensuring that it aligns with your overall design aesthetic.
Experiment with different combinations of font values to achieve the desired look and feel for your site's typography. Remember the essentials: always include size and family, use the slash for line-height, and provide fallback fonts in your stack.
Always include font-size and font-family in the shorthand
Use rem for body text so it scales with user preferences
Add a generic fallback family like sans-serif or serif
Set comfortable line-height with the slash syntax: 1rem/1.6
Use font: inherit on buttons and inputs when matching parent text
❌ Don’t
Omit font-family — the declaration becomes invalid
Put line-height before font-size or separate them without a slash
Use only pixel sizes if you want accessible, user-resizable text
Overload shorthand with every variant when a simple size + family suffices
Forget that unspecified shorthand parts may reset to initial values
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about font
Use these points when styling text with the font shorthand.
5
Core concepts
📝01
Shorthand
Many props, one line.
Purpose
Aa02
Size + family
Both required.
Rule
/03
Line-height
After size with /.
Syntax
B04
Weight & style
Before size.
Order
🔄05
Fallback stack
Generic family last.
Fonts
❓ Frequently Asked Questions
The font property is a shorthand that sets multiple font-related values in one declaration, including font-style, font-variant, font-weight, font-size, line-height, and font-family.
You must include font-size and font-family. The other components are optional, but if you include line-height it must come immediately after font-size with a slash, like 16px/1.5.
It sets font-size to 16px and line-height to 1.5. The slash separates size and line-height inside the font shorthand.
font-family only chooses the typeface. The font shorthand can set style, weight, size, line-height, and family together in one line.
Yes. font: inherit makes an element use the same computed font values as its parent, which is useful for buttons and form controls that do not inherit font settings by default.