HTML and CSS Reference
In-Depth Information
8.4.3.8. The font property
More often than not, you'll find yourself specifying more than one font-
related property at a time for a tag's text content display. A complete
font specification can get somewhat unwieldy. For example:
p {font-family: Times, Garamond, serif;
font-weight: bold;
font-size: 12pt;
line-height: 14pt}
To mitigate this troublesome and potentially unreadable collection, use
the comprehensive font property and group all the attributes into one
set of declarations:
p {font: bold 12pt/14pt Times, Garamond, serif}
The grouping and ordering of font attributes is important within the font
property. The font style, weight, and variant attributes must be specified
first, followed by the font size and the line height separated by a slash
character, and ending with the list of font families. Of all the properties,
the size and family are required; the others may be omitted.
Here are a few more example font style rules:
em {font: italic 14pt Times}
h1 {font: 24pt/48pt sans-serif}
code {font: 12pt Courier, monospace}
The first example tells the styles-conscious browser to emphasize <em>
text using a 14-point italic Times face. The second rule has <h1> text
displayed in the boldest 24-point sans-serif font available, with an extra
 
Search WWH ::




Custom Search