Chapter 8. Cascading Style Sheets

Style sheets are the way publishing professionals manage the overall "look" of their publications ? backgrounds, fonts, colors, and so on ? from a single page to huge collections of documents. Most desktop-publishing software supports style sheets, as do popular word processors, so the necessity of style sheets for HTML documents was obvious.

From the start, HTML focused on content over style. Authors are encouraged to worry about providing high-quality information and leave it to the browser to worry about presentation. We strongly urge you to adopt this philosophy in your documents ? don't mistake style for substance.

However, presentation is for the benefit of the reader, and even the original designers of HTML understood the interplay between style and readability ? for example, through the physical style and header tags. Style sheets extend that presentation with several additional effects, including colors, a wider selection of fonts, and even sounds so that users can better distinguish elements of your document. But most importantly, style sheets let you control the presentation attributes for all the tags in a document ? for a single document or a collection of many documents ? from a single master.

In early 1996, the World Wide Web Consortium (W3C) put together a draft proposal defining Cascading Style Sheets (CSS) for HTML. This draft proposal quickly matured into a recommended standard. In mid-1998, the W3C extended the original specification to create CSS2, which includes presentation standards for a variety of media besides the familiar onscreen browser, along with a several other enhancements.

Currently, no browser or web agent fully complies with the CSS2 standard. However, because we realize that eventual compliance with the W3C standard is likely, we'll cover all the components of the CSS2 standard in this chapter, even if they are not yet supported by any browser. As always, we'll denote clearly what is real, what is proposed, and what is actually supported.[1]

[1] In the fall of 2000, work began on CSS3. As CSS3 is still under construction and browsers have not yet even become fully compliant with CSS2, we focus on CSS2 throughout this chapter.