CSS Font Property
The font property in CSS is a shorthand property that allows you to set various font-related properties in a single declaration. It is a convenient way to specify multiple font-related values in one line. The font property can include the following sub-properties
- font-style: Specifies the style of the font (normal, italic, or oblique).
- font-variant: Controls the usage of small caps or normal capitalization.
- font-weight: Sets the thickness of the characters in the text (e.g., normal, bold).
- font-size: Specifies the size of the font.
- line-height: Sets the height of a line of text.
- font-family: Specifies the font family for the text.
Example
p { font: 20px Arial, sans-serif; } p { font: italic small-caps bold 12px/30px Georgia, serif; }You can click on above box to edit the code and run again.
Output
This is a paragraph. The font size is set to 20 pixels, and the font family is Arial.
This is a paragraph. The font is set to italic, small-caps and bold, the font size is set to 12 pixels, the line height is set to 30 pixels, and the font family is Georgia.