Applying Styles to Documents

You should consider several issues before, during, and after you use styles in your web documents and document collections. The first, overarching issue is whether to use them at all. Frankly, few of the style effects are unique; you can achieve most of them, albeit less easily and with much less consistency, via the physical and content-based style tags (e.g., <i> and <em>) and the various tag attributes (e.g., color and background).

To Style or Not to Style

We think the CSS2 standard is a winner, not only over JavaScript-based standards but also for the convenience and effectiveness of all of your markup documents, including HTML, XHTML, and most other XML-compliant ones. Most browsers in use today support CSS1 and many of the features of CSS2. The benefits are clear. So, why wouldn’t you use styles?

Although we strongly urge you to learn and use CSS2 stylesheets for your documents, we realize that creating stylesheets is an investment of time and energy that pays off only in the long run. Designing a stylesheet for a one- or two-page document is probably not time effective, particularly if you won’t be reusing the stylesheet for any other documents. In general, however, we believe the choice is not if you should use CSS2 stylesheets, but when.

Which Type of Stylesheet, and When

Once you have decided to use cascading stylesheets (for pain or pleasure), the next question is which type of stylesheet—inline, document level, or external—you should apply, ...

Get HTML & XHTML: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.