Previous Message
Next Message

[css-d] Hiding rules from IE5.5 using css comments

Sent by Edwardson Tan on 31 August 2002 07:07


I'm testing two hiding techniques, one for IE5.x/win and
another for Opera. Will post the one for Opera elsewhere.
Test results for various platforms and versions will be
appreciated.

Since Big John suggested his version of the simplified box
model hack a couple of weeks back I've been using the
backslash escape character to hide rules and properties from
IE5.5/win instead of employing child or sibling selectors.
Lately, however, I've tried using comments to do the same.

Example:

padding: 0 5%;
width: 100%;      /* for IE5.5/win */
width: /**/90%;   /* for other browsers, overrides above */
width: /* this too is hidden from IE5.5 */90%;

I find this technique 'safe' in that it's only a commment
and it validates. With it I can also hide any property
value from IE5.5 without worrying that I might inadvertently
escape letters a to f. As for drawbacks it's (obviously) 3
characters more than a backslash and NS4.x doesn't get
fooled by it (which can actually come in handy during those
times when only one stylesheet is served)

I've done some checking using IE6 and placing a blank space
between the comment and the value, eg. {color: /**/ red;},
hides some properties/values from it, but not all. By
ommiting any space IE6 doesn't mind the commment thus
effectively targeting only IE5.5.

Several questions: Has this bug/hack been documented? Does
it work for all IE5.x/win? How about IE for Mac? Other pros
and cons?

-- 
Edwardson
Previous Message
Next Message

Message thread: