Posted by Jarsto in Technology
August 8th, 2007 | No Comments »

I just figured out how to send a message to IE6 users only, without using any javascript to determine browser identity. I probably should have figured this one out much sooner, since it’s pretty much a variation on a trick I’ve used a number of times before.

Fact: only MSIE6 will read CSS starting with an underscore.

Fact: all browsers, including MSIE6 obey the last CSS they read if there are contradictory instructions.

So what do we do in our CSS?

div.ie6
{
display: none;
_display: inline;
}

And in our HTML/PHP?

<div class=”ie6″>If you can read this, you need a better browser!</div>

Easy enough, when you get right down to it. Just don’t ask me how long it took me to figure this out after learning about this little CSS peculiarity with IE6.

And if you’re looking to send a similar message to IE6 users, feel free to use this code.


Leave a Reply