XML technologies / CSS / Advanced websites with CSS / CSS property reference / font
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The shorthand property font lets you declare the font properties font-style, font-variant, font-weight, font-size, line-height and font-family together in a single declaration.
Unless one of the CSS constants listed below is declared, at least font-size and font-family must be declared. Other properties are optional and reset to their defaults unless specified in the declaration of font.
Inherited: yes
See also: font-style, font-variant, font-weight, font-size, line-height, font-family
Values
The syntax for the property font is as follows:
font: [style] [variant] [weight] size [/ line-height] family
Bracketed values are optional. The first three values— style, variant and weight —may appear in any order and accept the valid values of font-style, font-variant and font-weight respectively. The declaration of line-height comes immediately after size and a slash (/). For size, declare a CSS measurement, a percentage or a constant valid for font-size; for family, declare any valid value of font-family.
Since CSS2, an alternative syntax using shorthand constants is also valid:
font: konstante
konstante represents one of the following constants, each defining a detailed font configuration with fixed values for typeface, size, style, and so on:
captioniconmenumessage-boxsmall-captionstatus-bar
Fonts displayed with these constants may differ between browsers, operating systems and individual user settings.
Default value: none
Compatibility
CSS version: 1 (shorthand constants only in CSS2)
Works to some extent in all CSS-capable browsers, according to their support for individual font properties.
Examples
The following style rule uses every font property in font to define paragraph fonts:
p {
normal normal normal 11pt/12pt Myriad, Helvetica, sans-serif;
}The following style rule assigns elements caption a font definition using a constant:
caption {
font: caption;
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg