homepage Welcome to WebmasterWorld Guest from 54.211.97.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
CSS hack for IE6 and NN6
DrDoc

WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 677 posted 8:58 pm on Mar 1, 2003 (gmt 0)

With the release of IE6 the box model problem was solved. In any case, the famous box model hack [tantek.com] doesn't work in IE6.

So, in case you still want to hide stuff from IE6, here's a new hack you can use. I haven't tested it in older IE versions, but I suppose it should work in those too.

<style type="text/css">
#mydiv {
color: blue;
drdoc: ";
drdoc: "";

color: red;
background: silver;
/*";/* IE */
font-weight: bold;
}
#nextdiv {
color: red;
}
body {
background: navy;
}
</style>

Note: IE will continue parsing after /* IE */

The lines in bold are of course dummies. They could be called anything, preferably a property that doesn't exist. That way it won't cause errors in other browsers since they should ignore rules that aren't properly formed.

Here's another example:

<style type="text/css">
#mydiv {
color: blue;
drdoc: ";
color: red;
background: silver;
/*";/* IE */
font-weight: bold;
}
#nextdiv {
color: red;
}
body {
background: navy;
}
</style>

Note: IE will continue parsing after /* IE */
NN6 will hide the next rule

NN6/Mozilla will parse everything correctly, except the rule immediately following the hack, which will be ignored.

These hacks don't cause any problems in other browsers, as far as I know. If you notice anything, please post on here.

NN4 will of course choke on the hacks, but it's easy to work around that by using the comment hack for NN4.

<style type="text/css">
#mydiv {
color: blue;
/*/*/
drdoc: ";
drdoc: "";
/* NN4 */
color: red;
background: silver;
/*";/* IE */
font-weight: bold;
}
#nextdiv {
color: red;
}
body {
background: navy;
}
</style>

Hiding color changes is hardly what you want to do, though. But there are always margin issues and other bizarre bugs you might want to work around. I just used colors for simplicity.

Disclaimer: I do not recommend using hacks of any kind. I believe there are always other workarounds, especially if the hack will cause my HTML or CSS not to validate. But, for those of you that rely on hacks like these - you're welcome!

 

4serendipity

10+ Year Member



 
Msg#: 677 posted 6:18 am on Mar 2, 2003 (gmt 0)

I haven't seen that hack before. Thanks for pointing it out.

It does, however, seem like a complex work around for something that can be accomplished using other, simpler tricks such as child and/or attribute selctors, which will hide CSS from IE6.

Check out the following URL for details.

http://w3development.de/css/hide_css_from_browsers/summary/

[edited by: Nick_W at 1:20 pm (utc) on Mar. 2, 2003]
[edit reason] Only De-Linked ;-) [/edit]

DrDoc

WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 677 posted 5:01 pm on Mar 3, 2003 (gmt 0)

It does, however, seem like a complex work around...

True, but the "beauty" of it is that it lets you hide something from NN6/Moz if you want...

Hagstrom

10+ Year Member



 
Msg#: 677 posted 9:46 am on Mar 5, 2003 (gmt 0)

If you want to hide stuff from IE6, this is the easiest way:


<!--[if lt IE 6.0]>
<p>This won't display on Internet Explorer 6.0!
<![endif]-->

DrDoc

WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 677 posted 4:59 pm on Mar 5, 2003 (gmt 0)

Or, just ..

<![if!IE]>
This shows up in anything but IE
<![endif]>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved