You will probably use font properties frequently in your style sheets, so the W3C
specifies (and Internet Explorer supports) a shortcut
notation. Instead of setting the properties separately, you can combine them into
one property called font.
So, instead of:
p {font-style: italic;
line-height: 20pt;
font-weight: bold;
font-size: 12pt;
font-family: Times,serif;}
You can simply use:
p {font: italic bold 12pt/20pt Times, serif;}
Notes:
-
You can miss out most font options but you must always specify a size and at
least one font name
-
The order of properties is significant and is as follows: font-style,
font-variant, font-weight,
font-size and font-family.
The list of font families always comes last. It can include a comma-separated
list of family names
-
You may include a line height value (to define the line spacing). Adding a slash
("/") after the font size and then enter the line height e.g. 12pt/14pt
-
You can't set font-stretch
or font-size-adjust with
the font property
In CSS 2.0, you can also apply a font that matches the settings on the user’s PC
for any of the following:
-
Caption. Use the same font as objects with captions (buttons, labels, drop-downs
and so on)
-
Icon. Use the same font as icon labels
-
Menu. Use the same font as menus (drop-down menus and menu lists)
-
Messagebox. Use the same font as dialog boxes
-
Smallcaption. Use the same font as small controls
-
Statusbar. Use the same font as the window status bars
For example, if icons use Arial 10pt as a label, set the font
property to a value of icon
to match this.
|
|
More information
Font specification
font-family
font-size
font-size-adjust
font-stretch
font-style
font-variant
font-weight
font
@font-face
|