Which property is used as shorthand to specify a number of other font properties in CSS ?
In this article, we are going to discuss a property that is used as shorthand to specify different font properties.
The font property is a shorthand property for various font-related properties.
Shortening the code in Cascade Style Sheet (CSS) helps to specify all individual related properties into a single property. The font property is used as shorthand for various font properties like font-size, font-style, font-family, font-weight and font-variant.
- font-size: It specifies the size of the text.
- font-style: It specifies the style of text such as normal, italic, or oblique.
- font-family: It specifies the font for the text.
- font-weight: This property specifies how thick the text should be displayed.
- font-variant: It specifies whether the text is represented in small caps or not.
Note: The font-size and font-family are required properties and even if not specified, set the default values for the properties.
Example 1: Let’s look into the sample example program that uses the font property.
Example 2: In this example code, we will apply all font related properties in a single shorthand code.