CSS font Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The font property is a shorthand that sets an element’s typeface and related font values in one declaration. You can also set a system font with a single keyword such as caption.

It is a shorthand for font-style, font-variant, font-weight, font-stretch / width, font-size, line-height, and font-family. It is inherited.

Reset warning.

Using font also resets related longhands (such as font-feature-settings and font kerning) to their initial values. Set those again after the shorthand if you still need them.

CSS Syntax

syntax.css
font: [style] [variant] [weight] [stretch] size[/line-height] family | caption | menu | initial | inherit;

font-size and font-family are required in the shorthand form. font-family must be last.

Property Values

Part / ValueDescriptionTry it
size familyMinimum shorthand — size then familyTry it
size/line-height familySize, line-height (after a slash), then familyTry it
style weight size familyOptional style and weight before sizeTry it
small-capsOptional font-variant value in the shorthandTry it
caption / systemSystem font keyword (caption, menu, icon, …)Try it
inheritTakes the parent’s computed fontTry it

How to Use font

Write required size and family first, then add optional style, weight, or line-height when you need them.

  1. Choose a font-size and a font-family stack (required).
  2. Optional: put italic, bold, or small-caps before the size.
  3. Optional: add /line-height right after the size.
  4. Or use one system keyword (caption, menu, …) alone.
PieceRequired?Role
font-sizeYes (shorthand form)How large the text is
font-familyYes (shorthand form)Must be the last value
style / weight / variantNoGo before the size
/line-heightNoOnly right after size

Live Preview

Switch shorthand presets and watch size, weight, and family change together.

Size and family are required in the shorthand. System keywords like caption stand alone.

Sample

The quick brown fox jumps over the lazy dog.

font: italic bold 1.25rem Georgia, serif

CSS Examples

Each snippet focuses on the font shorthand. Use Try It Yourself for a live editor.

Example 1 — Size and Family

The shortest valid shorthand: size, then family.

CSS
<style>
  p {
    font: 1.125rem system-ui, sans-serif;
  }
</style>

<p>Hello CSS font shorthand.</p>
Try It Yourself

How It Works

  1. Set the size. 1.125rem is the font-size.
  2. Set the family last. system-ui, sans-serif is the fallback stack.
  3. Defaults fill the rest. Style, weight, and line-height reset to their initial values.
  4. One line. You do not need separate font-size and font-family rules for this case.

Example 2 — Size / Line-Height

Add line-height with a slash right after the size.

CSS
<style>
  p {
    font: 1.125rem/1.6 Georgia, serif;
  }
</style>

<p>Readable body text with spacing.</p>
Try It Yourself

How It Works

  1. Write size/line-height. 1.125rem/1.6 means size then line-height.
  2. Keep the slash. Without /, 1.6 would not be treated as line-height here.
  3. Family still last. Georgia, serif finishes the shorthand.
  4. Nice for body copy. Size and spacing travel together in one declaration.

Example 3 — Style and Weight

Put optional style and weight before the size.

CSS
<style>
  p {
    font: italic bold 1.25rem Georgia, serif;
  }
</style>

<p>Emphasized heading text.</p>
Try It Yourself

How It Works

  1. Optional parts first. italic and bold come before the size.
  2. Then size and family. 1.25rem Georgia, serif finishes the required pair.
  3. Order matters. Family must stay last; size comes after style/weight.
  4. Same as longhands. This matches setting font-style, font-weight, font-size, and font-family separately.

Edge Cases & Pitfalls

Most invalid font rules miss size, family, or the slash.

required

Size and family are required

font: bold alone is invalid. Include both a size and a family (unless you use a system keyword).

order

Family must be last

Put the typeface stack at the end. Style, variant, weight, and stretch go before the size.

slash

Line-height needs a slash

Write 16px/1.5, not a bare second number after the size without /.

reset

Shorthand resets other font settings

A font declaration clears related longhands to initial. Re-apply features like kerning or OpenType settings afterward if needed.

system

System keywords stand alone

font: caption is valid. Mixing extras like font: caption 12px invalidates the declaration. Prefixed system names (-webkit-*, -moz-*) are non-standard.

Browser Support

font is a browser typography shorthand. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

font

Supported in Chrome, Firefox, Safari, Edge, Opera, and IE. System font keywords and stretch values have long-standing support.

99% All major browsers
Google Chrome 1+
Full
Mozilla Firefox 1+
Full
Apple Safari 1+
Full
Microsoft Edge 12+
Full
Opera Supported
Full
Samsung Internet Supported
Full
Internet Explorer 4+
Full
font Widely supported

Bottom line: Safe everywhere for size + family shorthand. Prefer longhands when you only need to change one font setting without resetting others.

Key Takeaways

  • Role: one shorthand for style, weight, size, line-height, and family — or a system font keyword.
  • Required: font-size and font-family (family last).
  • Line-height: write size/line-height, then the family.
  • Reset: the shorthand clears related font longhands to initial values.

One line: font packs typography into one rule — size and family required, everything else optional.

Frequently Asked Questions

It is a shorthand that sets font-style, font-variant, font-weight, font-size, line-height, and font-family together. It can also set a system font with a single keyword such as caption.
You must include font-size and font-family. Other parts are optional. If you set line-height, write it after 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 in one line.
Yes. Declaring font resets related longhands such as font-feature-settings and font-kerning to their initial values, even if you do not set them in the shorthand.
It is Baseline and widely available in all modern browsers and older ones too. It is a browser typography property, not a Node.js feature.

Next: font-family

Learn how to pick a typeface stack with fallbacks.

font-family tutorial →

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.

8 people found this page helpful