To reduce code length, you can consolidate all individual font properties into a single property declaration.
The font property serves as a shorthand for:
Note: While specifying font-size and font-family is mandatory, if any other value is omitted, the default values are applied.
Example
Utilize the font shorthand property to consolidate multiple font attributes into a single declaration.
p.a { font: 20px Arial, sans-serif; } p.b { font: italic small-caps bold 12px/30px Georgia, serif; } |
Property |
Description |
font |
Consolidates all font properties into a single declaration. |
font-family |
Defines the font family for text. |
font-size |
Define the font size of text |
font-style |
Define the font style for text |
font-variant |
Determines whether text should be displayed in a small-caps font. |
font-weight |
Specifies the font weight. |