18.4. Other Font Settings
Compared to the hassles of
font-face
and
font-
18.4.1. Font WeightThe font-weight property specifies the weight, or boldness, of the type.
Values:normal bold bolder lighter 100 200 300 400 500 600 700 800 900 inherit Initial value:normal Applies to:All elements Inherited:Yes
Font weight can be specified either as a descriptive
It is evident that the numeric font-weight values are not useful when multiple weights are not available for the font. There's no harm in using them, but don't expect them to change the weights of an existing font. It merely looks for font weights that are already available. Figure 18-6. The effect of font-weight values
Unfortunately, the current browsers are inconsistent in support of the
font-weight
property,
18.4.2. Font Style
font-style
controls the
Values:normal italic oblique inherit Initial value:normal Applies to:All elements Inherited:Yes
Italic and oblique are both
<p style="
font-style: oblique
">This is a sample of oblique Times
as rendered in a browser.</p>
<p style="
font-style: italic
">This is a sample of italic Times
as rendered in a browser. </p>
Figure 18-7. Comparison of oblique and italic type set with the font-style property
18.4.3. Font Variant
The sole purpose of the
font-variant
property is to specify that text should appear as small caps. Small caps fonts use smaller uppercase letters in place of lowercase
Values:normal small-caps inherit Initial value:normal Applies to:All elements Inherited:Yes If a true small caps font face is not available, the browser may simulate small caps by displaying all caps at a reduced size. Figure 18-8 shows such a simulation using this style rule. <span style=" font-variant: small-caps ">lorem ipsum dolor sit amet,</span> consectetuer adipiscing elit. Pellentesque pharetra, urna in laoreet tincidunt, nunc quam eleifend libero, a tincidunt purus augue eu felis. Phasellus quis ante. Sed mi. Figure 18-8. Using font-variant for small caps
Unlike a true small caps typeface design, the
18.4.4.
|
| font |
[[<'font-style'> <'font-variant'> <'font-weight'>]? <'font-size'> [/<'line-height'>]? <'font-family'> ] caption icon menu message-box small-caption status-bar inherit
Uses individual property default values
All elements
Yes
When using the font property as shorthand for a number of font properties, the order in which the property values appear is important. All of these font rules show correct usage of the font property.
h1 { font: 1.75em sans-serif; } /* minimum value list for font */
h1 { font: 1.75em/2 sans-serif; }
h1 { font: bold 1.75em sans-serif; }
h1 { font: oblique bold small-caps 1.75em Verdana, Arial, sans-serif; }
The rule may include values for all of the properties or a subset, but it must include font-size and font-family , in that order, as the last two properties in the list. Omitting one or putting them in the wrong order causes the entire rule to be invalid. These examples are invalid:
h1 { font: sans-serif; } /* font-size omitted */
h1 { font: 1.75em/2 sans-serif oblique; } /* size and family come first */
Once you've met the font-size and font-family requirement, the rule may also include optional font-style , font-variant , or font-weight properties at the beginning of the rule. They may appear in any order, as long as they precede font-size . Another optional value is the line-height property (for adding space between lines) that appears just after font-size , separated by a slash ( / ), as shown here:
p { font: italic 12px/18px Georgia, Times, Serif }
It is important to know that when you use the shorthand
font
property, any property that is omitted will be reset to the initial setting (default) for that property. Be aware that an incomplete shorthand rule could
The
font
property provides a number of keywords that allow authors to apply font styles from the operating system into their web documents. This may be a useful tool for making a web application blend in with the
The font used for captioned controls (e.g.,
The font used to label icons
The font used in menus (e.g., drop-down menus and menu lists)
The font used in dialog boxes
The font used for labeling small controls
The font used in window status bars
Choosing one of these keywords applies all aspects of that font (family, size, weight) at once, although they may be overridden with specific font properties. If a particular font is not found, the user agent should approximate the font or substitute a default font. System font values are well-supported by current standards-compliant browsers.