9.1. Hiding Certain Styles from Netscape Navigator 4.x

Problem

You want to keep Netscape Navigator 4.x from using certain CSS rules. For example, Navigator 4.x doesn’t correctly inherit styles like font-family and color set for the body to elements like table, div, and p.

Solution

In a separate style sheet, place the CSS rules that you don’t want the Netscape Navigator 4.x browser to use. Then use the @import method to associate the “advanced” CSS rules (making sure that the advanced style sheet comes after the basic to override styles from the basic style sheet):

<link rel="stylesheet" type="text/css" media="all" title="Basic CSS" href="/basic.
css" />
<style type="text/css" media="all">
 @import "/css/advanced.css";
</style>

Discussion

Netscape Navigator 4 was the first Netscape browser to contain support for CSS. Unfortunately, Netscape was developing the browser while CSS was being finalized. Also, Netscape was supporting its own proposal, JavaScript Style Sheets, known as JSSS, and was basing Navigator 4 on that technology. So, when the W3C went with CSS instead, the Netscape engineers had to do some quick jury-rigging to fix their implementation. This is why you can turn off CSS support in Navigator 4 just by turning off JavaScript in the program’s preferences.

Because Navigator’s CSS implementation was essentially a remapping to its JSSS engine, actual CSS support for the implementation of such things as the @import method of associated styles to a web page was woefully incomplete. ...

Get CSS Cookbook 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.