That Norwegian Guy

Eystein Mack Alnæs

That Norwegian Guy random header image

IE7 css filter hack

March 20th, 2007 by Eystein

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

Tags: No Comments

Leave A Comment

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.