O'Reilly logo

CSS Pocket Reference, 4th Edition by Eric A. Meyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

font

Values:

[[ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'>] | caption | icon | menu | message-box | small-caption | status-bar

Initial value:

Refer to individual properties

Applies to:

All elements

Inherited:

Yes

Percentages:

Calculated with respect to the parent element for <font-size> and with respect to the element’s <font-size> for <line-height>

Computed value:

See individual properties

Description:

A shorthand property used to set all the aspects of an element’s font at once. It can also be used to set the element’s font to match an aspect of the user’s computing environment using keywords such as icon. If keywords are not used, the minimum font value must include the font size and family in that order, and any font value that is not a keyword must end with the font family. Otherwise, the font declaration will be ignored.

Examples:

p {font: small-caps italic bold small/
   1.25em Helvetica,sans-serif;}
p.example {font: 14px Arial;} /* technically correct,
   although generic font-families are encouraged for
   fallback purposes */
.figure span {font: icon;}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required