CSS Font Properties

Here, we look at the various font properties. These are the properties in the font namespace — those that include the word font at the start of their name.

CSS font properties enable you to change the look of your text. For example, you can assign a font family, apply bold or italic formatting, change the size and more.

CSS Font Family

The font-family property allows you to set the font family.

The font-family property accepts a list of different font families. This is because, not all users will have the same fonts installed on their computer. Therefore, as a designer/developer, you can provide a list of fonts, starting with your first choice, and ending with your last choice.

So, if the user doesn't have your first choice font, the second choice will be used for that user. If they don't have the second choice, the third choice will be used, and so on.

It's good practice to make your last choice a generic font family such as serif or sans-serif (depending on whether you want a font with serifs or not). This way, if none of the other choices are on the user's computer, their computer will choose a font that is on their computer, based on the generic family that you provide.

CSS Font Size

Enables you to set the size of the text. For info on the possible values, see the font-size page.

CSS Font Size Adjust

This property enables you to adjust the x-height to make fonts more legible. For more info, see the font-size-adjust page.

CSS Font Stretch

This property relies on the user's computer to have an expanded or condensed version of the font being used. For all possible values, see the font-stretch page.

CSS Font Style

The font-style property is used for specifying italic text.

CSS Font Variant

Enables you to set your text to use small caps. See font-variant.

CSS Font Weight

Enables you to set your text to bold. For more info, see font-weight.

CSS Font Property

The font property is a shorthand property that enables you to set all font properties in one go.