The Font Shorthand

suggest change

With the syntax:

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

You can have all your font-related styles in one declaration with the font shorthand. Simply use the font property, and put your values in the correct order.

For example, to make all p elements bold with a font size of 20px and using Arial as the font family typically you would code it as follows:

p {
    font-weight: bold;
    font-size: 20px;
    font-family: Arial, sans-serif;
}

However with the font shorthand it can be condensed as follows:

p {
    font: bold 20px Arial, sans-serif;
}

Note: since font-style, font-variant, font-weight and line-height are optional, they are skipped in this example. Using the shorthand resets the other font properties that are not given. The two properties the shorthand requires are font-size and font-family. If they are not both included the shorthand is ignored.

Initial value for each of the properties:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents