Forum Moderators: not2easy

Message Too Old, No Replies

How can I add element for just IE6?

         

CWebguy

12:13 am on May 10, 2009 (gmt 0)

10+ Year Member



Hey there, sorry if this has been answered. I am looking for a simple hack for inside a CSS file.

I have a div that works fine in FF and IE7+ but in IE6 gets bumped, so I am trying to reduce the width in just IE6.

right now I have

.sidebar
{
width:210px
rest of elements here...
}

How can I set the width as 210px in FF and IE7 but as 190px in IE6?

Thanks.

swa66

9:54 am on May 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are 2 ways to do it:

  • conditional comments: works, is self documenting and future proof

    I'd add this in the head of the html


    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="/ie6.css" />
    <![endif]-->

    and add all fixes for IE6 in IE6.css (you can do the same for the other legacy IE browser)

  • parser hacks: risky, but some still like it, I can't recommend it even if it's more contained in the CSS only

Do make sure you don't have IE6 in quirksmode (use a full doctype with nothing in front of it) and validate your code.