B.37. font

A shorthand property that allows you to set many font properties of an element with a single property declaration. With this one property, you can set the values of Section B.42font-style, Section B.43font-variant, Section B.44font-weight, Section B.39font-size, Section B.58line-height, and Section B.38font-family.

Unless you use one of the CSS2 constants (described below), you must specify a font-size and font-family. All the other properties are optional, and will be reset to their initial values if they are not specified (overriding any previous declarations of equal or lesser precedence for their values). The properties Section B.41font-stretch and Section B.40font-size-adjust are also reset to their default values by this property, even though you don't have the option of specifying your own values.

Inherited: Yes

See also: The individual font properties, listed above.

B.37.1. Value

The syntax of this property is as follows:

font: style
					variant
					weight
					size / line-height
					family
				

The values in square brackets are optional. The first three values—style, variant, and weight—may be specified in any order, and can take values allowed for font-style, font-variant, and font-weight, respectively. size is required, and can take any font-size value. line-height must come right after size if it is specified, can take any line-height value, and it is preceded by a slash (/). Finally, the family value can take any font-family value.

As of CSS2, an alternative syntax is available for this property:

font: constant
				

constant is one of the following constants, each of which corresponds to a full font specification (family, size, weight, etc.):

  • caption

  • icon

  • menu

  • message-box

  • small-caption

  • status-bar

The fonts associated with these constants vary between browsers, operating systems, and individual system configurations. The idea is that they should match the fonts in use elsewhere on the system so that user interface elements of the Web page can be made to match up with equivalent elements in local applications.

Initial value: none

B.37.2. Compatibility

CSS Version: 1 (constants added in CSS2)

All CSS-compatible browsers support this to some extent—generally one that's compatible with the limits of each browser's support for individual font properties.

B.37.3. Examples

This style rule uses all possible values to define a font for paragraph elements:

p {
  normal normal normal 11pt/12pt Myriad, Helvetica, sans-serif;
}

This style rule applies the system caption font to caption elements:

caption {
  font: caption;
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset