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:css, IE, filter, hack, InternetExplorer, IE6, IE7, star-hack
Blogged with Flock





2 responses so far ↓
Autumn // 27 November, 2008 at 6:54 pm |
[...] http://thatnorwegianguy.wordpress.com/2007/03/20/ie7-css-filter-hack/ */ *+html .topline-middle .nav li ul{ margin-top: 0; [...]
Quick Tip: Combine IE6 & IE7 style sheets into one CSS file | Ryan Roberts // 19 June, 2009 at 3:22 pm |
[...] star filter filter hacks and conditional comment are both well known methods of targeting Internet Exploder 6 and 7, and by [...]