CSS font properties

Font properties

To shorten the code, you can also specify all individual font properties in one attribute.

font The property is a shorthand for the following properties:

  • font-style
  • font-variant
  • font-weight
  • font-size/line-height
  • font-family

Example

Use shorthand declarations to set some font properties:

p.a {
  font: 20px Arial, sans-serif;
}
p.b {
  font: italic small-caps bold 12px/30px Georgia, serif;
}

Try it yourself

Note:font-size and font-family The value is required. If one of the other values is missing, the default value will be used.

All CSS font properties

Property Description
font Shorthand property. Set all font properties in one declaration.
font-family Specify the font family (font family) of the text.
font-size Specify the font size of the text.
font-style Specify the font style of the text.
font-variant Specify whether text is displayed in a small caps font.
font-weight Specify the thickness of the font.