HTML and CSS Reference
In-Depth Information
It cannot be stressed enough that font sizes are inexact. Web authors are
strongly encouraged to use relative sizes speciied in em and percentage units
in their CSS statements and leave it to the readers to set the overall metrics.
To save web authors time, CSS has a shorthand notation for specifying font
properties. It is conveniently called the
font
property. It has two formats:
font: <font-style> <font-variant> <font-weight> <font-size>
<font-family>
or
font: <keyword>
In the irst format, the
font-style
,
font-variant
, and
font-weight
property
values are optional. he
font-size
and
font-family
values are required. he
second format sets the font to match one of the fonts used by the operat-
ing system for user interface elements. he acceptable keywords are
caption
,
small-caption
,
icon
,
menu
, and
message-box
. he keyword
inherit
may also be
used to indicate that the font properties should be taken from the parent ele-
ment. Here are some examples:
p
{ font: bold 120% Verdana, Tahoma, sans-serif; }
h2
{ font: italic 18pt Times, "Times New Roman", serif; }
code
{ font: message-box; }
cite
{ font: italic large Georgia,Times,serif; }
When using the shorthand
font
property, font family names that contain
blanks should be enclosed in double quotes to avoid confusion. However, when
you specify the CSS in a style attribute, double quotes are already in use for
the entire attribute value, so the font family name should be enclosed in single
quotes. For example:
<h2 style="font: italic 18pt Times,'Times New Roman',serif;">...</h2>
he keyword values are seldom used. One of the problems with keyword
values is that the text is rendered in a ixed size determined by the operating
system and unafected by any
font-size
property set for the element. How-
ever, the
line-height
property is dependent on the
font-size
property, and it
is