Errors in Style Sheet Implementations

Next Previous Skip Next Skip Previous CSS
WebRing Home List
ring
sites Pick random site

This page (last updated on August 11, 1997) documents some errors in the major browsers in interpreting the specification of Cascading Style Sheets.

(If you are unfamiliar with style sheets, you might want to learn about them from the Web Design Group's Guide to Cascading Style Sheets, or you can buy the book I'm co-writing when it appears on bookshelves in mid-October.)

So far, there are two tests here:

  1. Inheritance
  2. Horizontal Rules and Backgrounds

You can also read about these tests.

Test 1: Inheritence of a BODY font style

A sample document was created with various headings, emphasis, strong emphasis, italics, bold, horizontal rules, a list, a table, a form section, an image, several font elements and superscripted text.

This document contains a simple style sheet, with three rules grouped to apply to the BODY of a document. The style sheet is shown here:

BODY { font: normal normal normal 12pt/13pt sans-serif; background: black; color: white; }

The three rules say:

  1. Apply a 12 point sans serif font, with 13 points of line height, that's normal in three ways: normal (not bold) font-weight, normal (not italic) font-style, and normal (not small caps) font-variant.
  2. Apply a black background.
  3. Apply a white text color.

These three rules should inherit their way down from the BODY element to all of the HTML elements contained in the body. The question is whether or not the default values of those HTML elements (for example, the larger font size of a level-one heading) should outweigh the inherited rule.

Although open to interpretation, the CSS1 specification seems to say that the default values of an HTML element (such as the bolding found in a <B> tag) are declarations that should outweigh the inherited declaration.

To test how the browsers have decided to resolve this issue, here are the results of the test document being rendered on various browsers on the Windows 95 platform.

The lesson here is that IE 3.02 and Navigator 4.01 treat inheritance much differently than IE 4.0 platform preview 2.

This can cause quite a few problems for style sheet authors. As David Perrell wrote recently on the W3C's www-style mailing list:

In any case it looks like prudent authors will have to declare style for all elements they use.

(You can read the archive of this mailing list for a discussion of whether or not inherited properties should outweigh the brower's initial values. You can also participate in a new project to write a style sheet that accurately describes the browsers' default behaviors.)

Alternately, you may have to create different style sheets for different browsers, and use scripting to select the appropriate style sheet for each style sheet-enabled browser. Todd Fahrner describes one such approach while demonstrating some (different) problems with CSS implementations.


Test 2: Styled Horizontal Rules and Backgrounds

This test uses a sample document made up of various styles for horizontal rules, as well as background styles.

The test document is available so you can see how your browser renders styled horizontal rules and backgrounds. (Please "view source" to see how the example was constructed.)

Here is how four popular browsers render this example document on my system.


Other Tests

Other tests might well appear here when I have time. Unfortunately, I've already uncovered quite a few other problematic examples.


About These Tests

These screen shots were created on two different Windows 95 systems, at 640x480x256, with default fonts and settings, (except for switching off the toolbars to show more of the test documents on-screen).

I would like to add more screen shots from different platforms, if there is a difference in how your browser renders any of the above tests. I don't currently have access to a Mac, so I'm very interested in seeing how the Macintosh versions compare.

Please send me your comments and screen shots (any format, I can convert). Let me know if something isn't working right for you, or if you have suggestions for how I can improve these tests, or for adding more tests.

There is a comprehensive body of tests available from some W3C's CSS test pages, maintained by one of the principal CSS1 authors, Håkon Wium Lie.


HTML 4.0: No experience required test site


Zeigen's Dilemma
  E. Stephen Mack (estephen@emf.net)