The CSS font
properties allow you to control the appearance of text by setting various font attributes such as font family, font size, font weight, and more.
The font-family
property specifies the typeface to be used for text. For example:
p {
font-family: 'Georgia', serif;
}
This paragraph uses the Georgia font.
The font-size
property sets the size of the font. It can be specified in various units such as pixels (px), ems (em), or percentages (%). For example:
p {
font-size: 24px;
}
This text is 24px in size.
The font-weight
property specifies the thickness of the font. It can be set to values like normal
, bold
, or numeric values from 100 to 900. For example:
p {
font-weight: bold;
}
This text is bold.
The font-style
property is used to set the style of the font, such as normal
, italic
, or oblique
. For example:
p {
font-style: italic;
}
This text is italic.
The font-variant
property is used to specify whether the font should be displayed in a small-caps or other variant. For example:
p {
font-variant: small-caps;
}
This text is in small caps.
The font-stretch
property allows you to make the font narrower or wider. For example:
p {
font-stretch: expanded;
}
This text is stretched.
The font
shorthand property allows you to set multiple font attributes in one declaration. For example:
p {
font: italic small-caps bold 20px 'Arial', sans-serif;
}
This text is italic, small caps, bold, and 20px in Arial font.