CSS hack for IE 6?

D

delerious

I've read about the child selector hack (using something like html>body as a
selector in the stylesheet), which is good when you want to use styles for all
non-IE browsers.

Is there a hack just for IE 6? I want to apply a style to IE 6 browsers but
not IE 5.x browsers. It would be OK if the hack worked for non-IE browsers
too, just as long as it excluded IE 5.x browsers.
 
S

Steve Pugh

I've read about the child selector hack (using something like html>body as a
selector in the stylesheet), which is good when you want to use styles for all
non-IE browsers.

Is there a hack just for IE 6? I want to apply a style to IE 6 browsers but
not IE 5.x browsers. It would be OK if the hack worked for non-IE browsers
too, just as long as it excluded IE 5.x browsers.

Have a look at http://centricle.com/ref/css/filters/ and the various
linked pages. Several ways to hide styles from IE5 but not reveal them
to IE6.

Steve
 
T

Toby A Inkster

delerious said:
Is there a hack just for IE 6?

There are various hacks for different combinations of browsers. By
combining several, it is usually possible to get a combination that works
in any browser you like.

Here is a hack to make some element (#mydiv) blue in IE 6, but red in
other browsers.

#mydiv { color: red; }
#mydiv {
\color: red;
c\olor: blue;
}
html>body #mydiv { color: red; }

Untested, but should work.

IE 6 sees the first three 'color' properties, but not the last. IE 5 only
sees the first two. Opera 6+ and Gecko see them all. As a result, IE 6
applies the blue colour and others use red.

Not sure what will happen in KHTML, but I think it should see what Opera
and Gecko see.

For more nice CSS hackism, see:

http://www.goddamn.co.uk/tobyink/styles/two-column-layout.css

That file does my two column layout for Opera 3.6+, Internet Explorer 4+,
Gecko and Konqueror 3. I think it's pretty nifty.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top