XML technologies / CSS / Advanced websites with CSS / Validation and backward compatibility / Making a CSS page backward-compatible / Browsers with limited CSS support
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
Browsers without CSS need little attention, but proprietary or faulty support is harder. Netscape Navigator 4, meaning versions 4.0 through 4.8, caused the worst problems. Perfectly designed, validated pages can become unreadable in these browsers.
Many designers ignore Netscape 4’s tiny market share. CSS can be disabled entirely there, giving users the same result as non-CSS browsers. (You could make the page work in Netscape 4, but this book will not cover that.)
Hiding stylesheets from Netscape 4
Two methods make Netscape 4 ignore all external stylesheets and display the page normally.
Using the @import at-rule
The first uses a CSS at-rule @import. An at-rule is a CSS directive or command beginning with @, usually inside tags <style> or, less often, linked external stylesheets. Netscape 4 does not recognize these commands and ignores them.
To link the external stylesheet corpstyle.css, add this line to the head:
<link rel="stylesheet" type="text/css" href="corpstyle.css"/>To hide it from Netscape 4, use an embedded stylesheet referring to it with the rule @import:
<style type="text/css">@import url(corpstyle.css);</style>The CSS file name is the argument of the operator url.
Hiding stylesheets from Internet Explorer 4
Netscape 4 deviates furthest from CSS, but Internet Explorer 4 is not much better. Hide stylesheets there too with the rule @import, with slightly different syntax:
<style type="text/css">@import "corpstyle.css";</style>Using the media attribute
The second method exploits Netscape 4’s handling of the attribute media on the tag <link>. The optional attribute media makes Netscape 4 ignore the stylesheet if its value differs from screen, as in this example:
<link rel="stylesheet" type="text/css" href="corpstyle.css" media="all"/>Normally, use all for the attribute media to hide the stylesheet. You could also use screen or print with the same effect.
Finding and handling problems
To find CSS problems in old browsers, a compatibility list is almost essential. Check the document against it. A comprehensive reference with browser notes appears in CSS property reference.
Netscape 4’s notes quickly reveal its biggest deviations:
in cascading
font-variantbackgrounds, especially positioning and images
word and letter spacing
vertical-alignmost box properties (see A simple CSS layout)
borders
all properties of
list-style.
Many subtler bugs exist. For relative font sizes, Netscape 4 incorrectly takes the parent’s values instead of using a relative size (see Using fonts with CSS).
Netscape 4 clearly causes major problems. Spending time fixing them only achieves a reasonably good, imperfect display in a faulty browser and is not worthwhile.
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg