CSS font Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Typography

What You’ll Learn

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.

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.

📝 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:

syntax.css
element {
  font: [font-style] [font-variant] [font-weight] font-size/[line-height] font-family;
}

Basic Example

font-basic.css
p {
  font: italic small-caps bold 16px/1.5 Arial, sans-serif;
}
font: 1rem/1.6 system-ui, sans-serif; font: bold 18px Georgia, serif; font: italic 14px/1.4 Arial, sans-serif;

Default Value

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.

⚡ Quick Reference

QuestionAnswer
Shorthand forfont-style, font-variant, font-weight, font-size, line-height, font-family
Required valuesfont-size + font-family
Applies toAll elements
Inherited (components)Yes — longhand font properties inherit
Common patternfont: 1rem/1.6 system-ui, sans-serif;

💎 Property Values

The font shorthand combines values from these individual properties:

ComponentDescription
font-styleDefines the style of the font. Common values: normal, italic, and oblique.
font-variantControls small-caps. Values: normal and small-caps.
font-weightSpecifies font weight. Values include normal, bold, and numbers 100 through 900.
font-sizeSets text size in units like px, em, rem, or %. Required in the shorthand.
line-heightSets line box height. Written after font-size with a slash, e.g. 16px/1.5.
font-familySpecifies 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;

Common font Shorthand Patterns

font declarationWhat it setsTypical use
font: 1rem/1.6 system-ui, sans-serif;Size, line-height, familyBody copy, articles
font: bold 1.5rem Georgia, serif;Weight, size, familySection headings
font: italic 14px/1.4 Arial, sans-serif;Style, size, line-height, familyQuotes, captions
font: inherit;All font values from parentButtons, inputs

👀 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.

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>
Try It Yourself

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.

font-body.css
body {
  font: 1rem/1.6 system-ui, sans-serif;
}
Try It Yourself

How It Works

1rem/1.6 sets size relative to the root element and line-height as a unitless multiplier for comfortable reading.

💬 Headings & Form Controls

Style headings with weight and size, or reset form controls with inherit.

Example 3 — Bold Heading Font

Set weight, size, and a serif family for a section title.

font-heading.css
h2 {
  font: bold 1.5rem Georgia, serif;
}
Try It Yourself

How It Works

You only need to include the components you want to change. Unspecified values reset to their initial defaults for that element.

Example 4 — font: inherit on Buttons

Form controls often use system fonts. Use font: inherit so buttons match surrounding text.

font-inherit.css
button {
  font: inherit;
}
Try It Yourself

How It Works

The button copies the parent's computed font values, keeping typography consistent in forms and toolbars.

♿ 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.

🖥 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 Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions
Full support
Opera All modern versions
Full support
font property 99% supported

Bottom line: font is safe for all modern projects. Split into longhand properties when you need to override only one value later.

🎉 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.

💡 Best Practices

✅ Do

  • 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

Key Takeaways

Knowledge Unlocked

Five things to remember about font

Use these points when styling text with the font shorthand.

5
Core concepts
Aa 02

Size + family

Both required.

Rule
/ 03

Line-height

After size with /.

Syntax
B 04

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.

Practice in the Live Editor

Open the HTML editor, change font shorthand values, and preview how size, weight, and family affect your text.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful