XML technologies / XML / XML in a Nutshell / Cascading Style Sheets (CSS) / Font properties
(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)
Fonts are among the most basic things designers control with CSS. Is the text italic? Is it bold? Which font and size are used? CSS provides properties to specify these important characteristics of text. In particular, you can set the following properties:
font-familyThis property is a comma-separated list of font names in order of preference. The last item should always be one of the generic names
serif,sans-serif,monospace,cursiveorfantasy. Names consisting of several words, such as “Times New Roman”, should be enclosed in quotation marks.font-styleThe value
italicspecifies that an italic version of the font should be used if available. The valueobliquespecifies that the text should be slanted rather than using a specially designed italic version. The default isnormal(neither italic nor slanted). An element can also inherit its parent’sfont-style. To do so, set the valueinherit.font-sizeThis property sets the font size. It should be specified using one of the values
xx-small,x-small,small,medium,large,x-largeorxx-large. Alternatively, it can be specified as a percentage of the parent element’sfont-size. You can also use a length, such as0.2cmor12pt, although this approach is suitable only for print media.font-variantIf this property is set to
small-caps, lowercase letters are displayed as small capitals, LIKE THIS, instead of ordinary lowercase letters.font-weightThis property specifies how bold or light the text is. It is generally set using one of the keywords
normal(default),bold,bolderorlighter. It can also be set to a multiple of 100, from100(lightest) to900(boldest). However, not all browsers necessarily support nine distinct font weights.font-stretchThis property sets the space between letters to make the text more or less compact. Valid values are
normal(default),wider,narrower,ultra-condensed,extra-condensed,condensed,semi-condensed,semi-expanded,expanded,extra-expandedandultra-expanded.
For example, this rule uses all these properties to turn the element gericht into an impressive heading:
gericht {
font-family: Helvetica, Arial, sans-serif;
font-size: x-large;
font-style: italic;
font-variant: small-caps;
font-weight: 900;
font-stretch: semi-expanded
}
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from the book "XML in a Nutshell" is subject to the same conditions as the printed edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de
back to top