Applying Styles to Documents

There are several issues you should consider 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; most can be achieved, 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 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 style sheets for your documents, we realize that creating style sheets is an investment of time and energy that pays off only in the long run. Designing a style sheet for a one- or two-page document is probably not time-effective, particularly if you won’t be reusing the style sheet for any other documents. In general, however, we believe the choice is not if you should use CSS2 style sheets, but when.

Which Type of Style Sheet and When

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

Get HTML & XHTML: The Definitive Guide, 5th 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.