Home > Articles

Browser Support for CSS

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

To be able to master the full power of Cascading Style Sheets, you need to understand the biggest issue related to using CSS—browser support. No other Web-related technology has been more limited by poor browser implementation than Cascading Style Sheets. However, the situation continues to improve, as recent browsers are getting closer and closer to full support for CSS.

In this hour, you'll learn

  • What the browser problem is and why it's a problem

  • The general categories of browsers and how each type affects your CSS Web designs

  • The essential need for workarounds and how to measure the cost of failure

  • How the current browsers use Cascading Style Sheets

  • How to read the Browser Support Report Card found in each subsequent hour of this book

The Browser Problem

A Web browser is the essential Internet access tool of the early twenty-first century. Browsers are becoming indispensable to business, education, and personal communication. They create a common platform upon which Web-based applications can be built, with an HTML framework driving e-commerce, business-to-business transactions, Web-based learning, and online communities. Hundreds of thousands of pages of new information are added to the Web each day. Cascading Style Sheets play a crucial role in this adolescent communications medium not only by providing a pleasant visual layer on the surface of these Web applications, but also by potentially reshaping the entire user experience.

So what's the problem? In short: Web browsers are terrible at CSS.

There are a variety of reasons for this. Some browsers, such as Netscape 3, were created before the CSS specification was published. Other browsers are limited in what they're meant to do: Lynx is a text-only browser and doesn't do CSS at all, whereas WebTV terminals understand only a subset of CSS. Some browsers jumped the gun; Microsoft is notorious for jumping the gun and using draft specifications of standards in their browsers. And sadly, some browsers are just plain bad. They may seem to function normally, but when it comes to consistent and standardized support for CSS, they fall very short.

The good news is that the problem is being solved. Slowly but surely, each new major browser release is better than the last, and you can get pretty decent, though not perfect, CSS implementations from Mozilla, Netscape 6, Opera, and certain versions of Internet Explorer.

How Browsers Deal with CSS

When a browser encounters anything—from CSS rules to HTML, JavaScript to Flash multimedia—it has three choices as to what it can do. If the browser has been programmed to understand the thing it has encountered, it will attempt to display it according to the specification. If it has no idea what it has come across, it can ignore it. Both of these options can be considered "doing the right thing." Or, the browser can do the wrong thing. It can get confused; it can display in some nonstandard way; it can crash. This third option is the least desirable and is the primary root of our problem.

Cascading Style Sheets were designed from the start to degrade gracefully. This means that if your CSS rules aren't recognized for some reason, your page will still be usable and the content accessible. Because we've separated presentation from content, our content should be able to stand on its own, albeit not as beautifully, once our presentation is removed. At least, that's the theory.

In practice it's not nearly as easy as that. To be an effective CSS author, you'll need to know not only what works in any given browser—or in most or all of them—but also what happens when it doesn't work. Is it as simple as your style not being applied correctly and you losing a bit of decoration, or is it as serious as your entire layout being disrupted and content being lost?

To understand how browsers deal with CSS, I've divided them up into four categories: older browsers, which pre-date the CSS specification and thus ignore it completely; limited browsers, which don't even attempt to support all of CSS; broken browsers, which try to provide CSS functionality but fail horribly in some manner; and compliant browsers, of which there are sadly few to none. Each category of browsers will treat Cascading Style Sheets differently, and it's important to understand what those differences are.

Older Browsers

Older browsers are those that existed before Cascading Style Sheets were even a glimmer in the W3C's collective eye. Netscape 3 is the classic example of an older browser, and it does exactly what it's supposed to do: it ignores CSS entirely. If you try to visit a Web page styled with CSS, Netscape 3 won't notice a single rule you've written. The style sheet won't even load.

This is actually ideal behavior for older browsers; with CSS designed for backwards compatibility, most CSS-based Web sites should still work, although they may be somewhat boring in appearance. Because Netscape 3 is ignoring all CSS rules, we know exactly what it will do with them; there's no guesswork necessary on the part of the author. You won't have to do anything special to support these types of browsers, except for testing your designs to see if they still function without CSS.


You can simulate an older browser by configuring a newer browser to deliberately ignore CSS in the preferences settings for each browser. By doing so, you can check to see if your designs work in browsers that don't understand CSS; a properly designed style sheet should be perfectly understandable in an ancient browser, such as Netscape 3.

Limited Browsers

Limited browsers are those that are not intended to be full-fledged general-use multimedia Web browsers; instead, they serve a very specific function and thus don't have a need for all the capabilities found in CSS.

A limited browser is troubling because it supports only a subset of Cascading Style Sheets—and not one that's broken cleanly along the lines of the CSS Level 1 and CSS Level 2 specifications. Microsoft's WebTV is an example of this type of browser; it supports only a small number of CSS properties, and not all of them. Another example is EmacSpeak, a screenreader for the visually impaired that supports aural CSS but not most visual formatting properties.

Supporting these browsers can be difficult, but they tend to be uncommon in practice, and usually the subsets of CSS they support are intelligently chosen, such as how EmacSpeak doesn't support visual properties but has a good reason for not doing so. Testing your design in an older browser (or one with CSS purposely disabled) is usually enough to cover limited browsers, although if you're designing specifically for audiences using these types of browsers, you may want to have a copy for your own testing purposes.

Broken Browsers

The worst kind of browser is one that is simply broken when it comes to CSS, despite whatever claims the provider makes to standards compliance. A broken browser is one that, when given perfectly legitimate Cascading Style Sheets rules, doesn't present a Web surfer with anything she can use, but instead displays a mishmash of styles where information gets lost. The difference between an older browser and a broken browser is that older browsers don't try to display CSS, and broken browsers try and fail horribly.

Internet Explorer 3 was the first browser to implement any CSS, but it did an overall bad job at it, based in part on the fact that they coded to a specification that was still being written at the time. When the final version of CSS Level 1 came out, it was quite different from Internet Explorer 3's attempt to implement CSS support.

Fortunately, Internet Explorer 3 has almost passed into memory, replaced by newer versions of Internet Explorer that are closer to the CSS specification, meaning that the buggy CSS implementation in Internet Explorer 3 really isn't a factor in current CSS usage.

The current front-runner in broken browsers—causing the most headaches for CSS developers around the world—is Netscape 4. Unlike Netscape 3, Netscape 4 does indeed attempt to support Cascading Style Sheets but fails miserably in many ways. For example, Netscape 4 doesn't understand many of the key CSS properties needed to lay out a page, set font styles, or align text.

To account for the broken browsers out there, it's necessary to understand how they're broken and what happens when you give each browser some CSS rules that it doesn't understand. In some cases, the broken browser will just ignore your CSS, as is the case with a limited or older browser; in others, it may do something horribly wrong. In this book we'll point out those problems and help you design CSS that will work on as wide a selection of browsers as possible.

Compliant Browsers

Working with a completely CSS-compliant browser is a joy—or it would be, if such a creature existed. At the moment there are no browsers that completely support all of the Cascading Style Sheets Level 2 specification, and only a handful that can legitimately claim full CSS Level One support.

Luckily, there's plenty of motion in the direction of full support, which means things are only getting better with each released browser version. Browsers that are very close to being compliant with the standard include—starting with the most compliant—Mozilla, Netscape 6, Opera 5 and 6, and recent versions of Internet Explorer, especially for Macintosh.

Coding CSS for a compliant browser is simply a matter of following the standard and reaping the benefit of your work. Unfortunately, this idyllic vision is still not yet a reality, as near-compliant browsers constitute only a small fraction of the browsers in use. For the foreseeable future, you'll need to keep in mind the needs of users without fully CSS-compliant browsers, and that means using workarounds when necessary.

The Importance of Workarounds

Because there are so many broken browsers out there, it's often necessary to use a work- around to effect the same functionality you would get on a compliant browser. A workaround is a hack—a nonstandard way of getting a certain result that bends and tweaks the syntax of CSS or HTML in order to produce the type of style effects you're trying to achieve.

A good workaround is one that stays within the published standards—CSS and HTML primarily—so that it doesn't break on browsers that are compliant with the standards. A partial workaround is one that gives a similar effect but doesn't fully measure up to the kind of styling you could do if the browser were standards-compliant.

Workarounds in This Book

Whenever possible, I've identified useful workarounds to compensate for browser limitations. These are formatted like this, as a tip, with the titles of the affected browsers in the heading of the tip.

For some browser limitations and bugs, there are simply no viable workarounds that give the same functionality; in those cases you will have to make a difficult choice—include the CSS despite browser limitations or leave it out entirely. The basis for this decision is the cost of failure.

The Cost of Failure

The cost of failure is simply an understanding of what will happen if you use specific CSS rules or properties that aren't understood by the browser.

In some cases, you'll want to use CSS properties that aren't well supported; you may figure that the cost of failure is low enough that you don't mind some users missing out on a special styling if it improves the site for those users with more advanced browsers. In other cases, you may decide you can't take that chance, and you'll have to make a choice whether to support the broken browsers with workarounds or ignore that audience.

For example, consider a CSS rule that makes the first letter of each section stand out large in a stylized font. This may just be simple decoration, and if the font is normal sized in some browsers, so be it; it may not affect at all the way your page functions.

Browser Compatibility Charts

A browser compatibility chart is an invaluable resource for anyone doing serious CSS work. What is it? A compatibility chart lists every CSS property in a matrix, cross- referenced with a number of different browsers (including various version numbers and platforms). For example, if you want to know if the Netscape 4 browser supports the color property, you can consult a compatibility chart. For each property you look up, you'll see whether or not it's supported by the browser, and if there are any special notes or known bugs in the implementation.

The best-known CSS browser compatibility chart is maintained by Eric Meyer as part of the WebReview site and is located at http://www.webreview.com/style/; I highly recommend bookmarking that site and referring to it as you test your CSS-based designs. Another good browser compatibility chart is from WestCiv, the makers of the Style Master CSS editor; their charts are at http://www.westciv.com/style_master/academy/browser_support.

In this book, I take a complementary approach to reporting compatibility; instead of rating the browsers, I give each CSS feature or property a grade at the end of each hour. This grade reflects not only the browser support but also the cost of failure in nonsupporting browsers. This will let you make an informed choice when creating your cross-browser CSS, and avoid those properties or features that are not safe yet for general use.

Web Standards and You

As you know, CSS is defined by the Cascading Style Sheets Level 1 and Level 2 recommendations from the World Wide Web Consortium. These recommendations function as standards for the CSS language.

Standards are a good thing for developers; the more the browsers support the standards, the easier it is for us to create expressive and attractive designs in CSS and know they'll work reliably. Increased support from standards, the browser makers, the Web developer community, and the Web software manufacturers will only make our jobs easier.

One group of Web designers decided to take their support for standards public and founded the Web Standards Project to encourage browser makers to adhere closely to the CSS recommendations and other Web standards. In addition to their advocacy work, the Web Standards Project site contains useful FAQs and links on standards support. Their URL is http://www.webstandards.org/.

  • + Share This
  • 🔖 Save To Your Account