IE7 css filter hack

After much searching I found a css filter which targets IE7 only. I’m not going to enter the hack or not hack discussion, I’ll just say that sometimes you gotta do what you gotta do. The old star-hack filter for IE6 is fixed in IE7, but the solution wasn’t to far away. There is now the star-plus hack.

IE6 filter: * html #foo { new: value; }

IE7 filter: *+html #foo { new: value; }

But it is not straight forward. For reasons I don’t know, you can’t putthem together, say if you want the same value for all of IE. This will not work for IE7:

* html #foo, *+html #foo { new: value; }

So the whole rule must be repeated. But that is not all. For more reasons, also unknown to me, the star-plus filter will not always work. Then I must use the slightly more elaborate star-firstchild filter.

*:first-child+html #foo { new: value; }

I know sometimes this is needed, but if I have control of things myself I much prefer using conditional comments. Or not supporting out of date browsers.

Test, discussion and original post at Brothercake.

technorati tags:, , , , , , ,

Blogged with Flock


2 responses to “IE7 css filter hack

  1. Pingback: Autumn

  2. Pingback: Quick Tip: Combine IE6 & IE7 style sheets into one CSS file | Ryan Roberts