skip to content rich footer

stevenclark.com.au

subscibe to the StevenClark.com.au rss feed

Serving CSS to Appropriate Browsers

One of the questions that gets asked less often now is how do we handle those browsers which are so old and sad, the one’s our grandmother’s have perched on their crocheted tablecloths? Don’t they screw up when they come across a complex CSS layout? And, if that’s so, then what do we do to incorporate these users into our larger plan for a better, more accessible and practical web experience? This is particularly important for government websites and anyone having to provide usable content to very old browsers, either by law, necessity or policy. In common speak, Netscape 4 and other old browsers crap up your fantastic layout! No big surprise.

The short answer is we create a base case stylesheet that older browsers can understand. Something unstrikingly acceptable to even the most outdated browsers out there. And, we hide our advanced stylesheet behind a variant of the @import stylesheet rule.

Rather than explaining the everything and the all of @import I’ll simply refer to the CSS-Discuss Wiki’s page on @import and let you do the general reading yourself (because I’m lazy - coders are lazy by nature). Depending on the syntax you use to import your stylesheet various browsers will be excluded from displaying your more complex layout.

So the trick really is simple. Older browsers get the first “basic.css” stylesheet and the newer browsers get both. Voila. Progressive enhancement and graceful degradation at work. The more advanced stylesheet overrides any unwanted style rules from the basic.css file.

<link rel="stylesheet" type="text/css" href="basic.css" />
<style type="text/css"> @import url("advanced.css"); </style>

[Note: 5 July, 2008. Oops apologies for having typos in that original code snippet, shows never to post and run. Bugger. Fixed now. Apologies.]

Importing stylesheets gets a lot more interesting than this example but its a good strategic jumping off point for your CSS strategy. The BBC.co.uk has a page on Cascading Style Sheets (CSS) Standards v1.1 which offers an overview of how they approach the responsible use of Cascading Stylesheets. All organisations might think of producing similar documents for distribution and guidance internally. BBC.co.uk seem to do this well. If you search their site they have all sorts of design policy and guidance documents of a particularly high quality.

Articles are licenced under a Creative Commons Licence but copyright of images is retained by © Steven Clark 2007 - 2008

2 Responses to “Serving CSS to Appropriate Browsers”

  1. steven

    Steven (me): Why was there a typo in the code snippet?

    Steven (other_me): Because I’m dumb, was tired and was required to rush into the loungeroom (Friday night).

    Steven (me): But it was just a plain stupid typo in the snippet to put a closing style tag after a link tag. Doesn’t this make you a bit embarrassed?

    Steven (me): Aww its the weekend, Stevie.

    [inspired by Stevie and Stevie and Stevie and Stevie and Stevie and of course a special pat on the back for Stevie from the Clone House]

  2. Strategic CSS is Management Driven : StevenClark.com.au

    [...] use @import to call your main stylesheet (sitewide.css) for more advanced browsers using the screen media [...]

skip to top of page

Currently Reading

Andy Clarke's Transcending CSS: the fine art of web design has been sitting on my bookshelf for several months and I've finally made the time to read it from end to end. My favourite thing about this book from the outset is that it's a designer's book, rather than a technician's manual, for web designers. The artwork and direction in Transcending CSS is enhanced by the attention to detail in the feel and texture of the book itself, the size of it's pages and the feel of the cover in your hands. It's definately a book that affords the act of being read. Looking forward to it.