Course contentsShow
← Web Development
Lesson 179 of 2,9823. CSS FundamentalsFree lesson

The Font Shorthand Property

Combine multiple font properties into a single declaration using the font shorthand syntax.

The Font Shorthand Property

You'll learn how to write five or more font-related CSS properties in a single, compact line.

What Is Font Shorthand?

Instead of writing separate declarations for font-style, font-variant, font-weight, font-size, line-height, and font-family, CSS lets you combine them all into one font property. Think of it like ordering a combo meal instead of ordering each item separately — you get everything you need in one go.

The Syntax

The font shorthand follows a specific order:

font: [font-style] [font-variant] [font-weight] font-size[/line-height] font-family;

Required values: You must include font-size and font-family, in that order.

Optional values: Everything else is optional and must come before the font size.

Examples

/* Basic: size and family only */
font: 16px Arial, sans-serif;

/* With line-height */
font: 16px/1.5 Georgia, serif;

/* Full syntax */
font: italic small-caps bold 18px/1.6 "Helvetica Neue", sans-serif;

Notice the slash (/) between font size and line height — that's how you include both in the shorthand.

Why Use It?

The font shorthand makes your CSS cleaner and faster to write, especially when setting multiple font properties at once. However, be aware: it resets any font properties you don't specify to their default values, so use it when you want to set everything fresh.

Key Takeaway: The font shorthand combines font properties into one line, requiring font-size and font-family while optionally including style, variant, weight, and line-height (with / syntax).