Skip to main content

The CSS Font Shorthand Property

To make the code shorter, you can set all the font properties in one declaration.

The font property is a shorthand for: font-style, font-variant, font-weight, font-stretch, font-size, line-height, and font-family.


Rules for the CSS Font Shorthand Property

  1. The font-size and font-family values are required. If any other value is missing, its default is used.
  2. If set, font-style, font-variant, and font-weight must come before font-size.
  3. If set, line-height must come right after font-size, separated by a slash, like 15px/30px.
  4. font-family must be the last value.

Example

Three paragraphs set several font properties at once with the font shorthand.

Prompt
An HTML page that uses the font shorthand property. In an internal <style> block, make three paragraph classes: a with "20px Arial, sans-serif"; b with "italic bold 16px Arial, sans-serif"; and c with "italic small-caps bold 15px/30px Georgia, serif". Add a paragraph of each class.
Output: complete HTML page

All CSS Font Properties

A summary of the font properties:

  • font — sets all the font properties in one declaration.
  • font-family — sets the font family.
  • font-size — sets the font size.
  • font-style — sets the font style.
  • font-variant — sets whether the text uses a small-caps font.
  • font-weight — sets the weight of the font.