View Full Version : How can I make a div show up only in IE6 and below?

Geezer D
06-02-2008, 04:39 AM
My site uses some fixed position divs, so it's a horrendous mess in IE6 and below, so I was wondering if I can have a div show up just in IE6 and below?

To say something like "Upgrade to IE7, or better yet, get Firefox".

Maybe with a browser sniffer script? Or just using CSS?

Thanks in advance.

06-02-2008, 04:54 AM
You can use IE conditional comments for that. A good approach because it is a supported feature, not a hack:

<!--[if lt IE 7]>
<div>Whatever's here, only IE 6 and below will see.</div>

The meaning is literally 'if less than IE 7'. This will only be looked at by IE 5+. All others will see it as a comment (thus ignore the div), and IE 7 will see it as a conditional comment to ignore.