The font property is a shorthand property for setting font-style
, font-variant
, font-weight
, font-size
, line-height
and font-family
at the same place in the style sheet.
font: [ <font-style> || <font-variant> || <font-weight> ]? <font-size> [ / <line-height> ]? <font-family>
font: caption | icon | menu | message-box | small-caption | status-bar | -moz-window | -moz-document | -moz-workspace | -moz-desktop | -moz-info | -moz-dialog | -moz-button | -moz-pull-down-menu | -moz-list | -moz-field
font: inherit
Using the font
shorthand property sets the longhand properties as specified, and sets all other font-related properties to their initial values.
See font-style
, font-variant
, font-weight
, font-size
, and font-family
for legal values of each property.
System fonts can also be specified using the font
property, instead of specifying individual longhand properties:
/* Set the font size to 12pt and the line height to 14pt. Set the font family to sans-serif */
p { font: 12pt/14pt sans-serif }
/* Set the font size to 80% of the parent tag or default value (if no parent tag present)
and set the font family to sans-serif */
p { font: 80% sans-serif }
/* Set the font weight to bold, the font-style to italic, the font size to large,
and the font family to serif. */
p { font: bold italic large serif }
The font-size
and font-family
parts of the shorthand are mandatory. Omitting them is a syntax error, and causes the entire declaration to be ignored.
Properties for which no values are given are set to their initial value, which is normal for all properties that can be omitted (font-style
, font-variant
, font-weight
, and line-height
).
The font-size-adjust
property is also set to its initial value (none) when the font
shorthand property is specified.
| Navegador | Versão mais antiga |
|---|---|
| Internet Explorer | 3 |
| Netscape | 4 |
| Opera | 3.5 |
font
font-family
,
font-size
,
font-size-adjust
,
font-style
,
font-variant
,
font-weight
,
line-height
Page last modified 00:13, 23 Jul 2007 by Verruckt