6 of 313 menu

The font property

The font property is a shorthand property in which you can use the following CSS properties: font-size, font-style, font-weight, line-height, font-family, font-variant.

Syntax

selector { font: [font-style|font-variant|font-weight] font-size [/line-height] font-family; }

The required properties are font-size and font-family, the rest can be omitted while maintaining order.

The font-style, font-variant, font-weight properties can be rearranged in any order relative to each other.

Please note that the line-height property is written with a slash after the font-size property.

Example

Let's make italic text of 15px size, with Arial type, and line spacing of 30px:

<p> some text... </p> p { font: italic 15px/30px Arial; text-align: justify; }

:

Example

Another example:

<p> some text... </p> p { font: bold 16px/20px "Times New Roman", Georgia, serif; text-align: justify; }

:

Example

Let's assign only a font size and family, omitting other properties:

<p> some text... </p> p { font: 18px Arial; text-align: justify; }

:

Example

If you set only a font size, it will not be applied, since the font family must also be specified:

<p> some text... </p> p { font: 30px; text-align: justify; }

:

byenru