Hacks for various flavors of IE
There’s an article on the Front End about a new parsing bug that was introduced in IE7 that now allows us to target in ONE stylesheet the different IE versions. It works like this:
`
p.styleme { color:red } /* IE7 */
* html p.styleme { color:blue } /* other IE */
*|html p.styleme { color:pink } /* FF, Opera, Konqueror, Safari */
`
Another example off the CSS-Discuss list–
`
.clearing { display:none } /* IE 6 & 7 */
*|html .clearing { display:block } /* everything else */
`
Which came with a caveat:
that’s invalid in CSS2.1. It is valid CSS3 as far as I can tell. but the W3 vaildator claims that it’s not which looks like a bug in the validator to me. Of course, trying to explain that to some clients may be tricky.Moreover, you’re also going to be targeting older browsers that don’t understand the namespace selector either which may or may not be the
result you’re after.
So the bottom line is to use this with care. Though the Front End blog has a distaste for IE stylesheets fed in via conditional comments, I don’t share that distaste. If hacks are fed via conditionals the validator is immaterial since it will never see those styles, however with this particular hack you’re showing stuff to the good browsers so . . . can’t get hidden. Hmm. I think I’ll stick with CCs for most stuff.
Truthfully, though, I’ve been finding in working with IE7 for awhile now, that it needs most of the same little stupid spacing hacks that IE6 does . . .









June 24th, 2007 at 12:39 pm
[…] I know some purists will argue that using conditional comments is hacky and awful, since conditional comments are a proprietary call and browser specific code, and thise purists would rather use one stylesheet and more wacko IE specific filters, but in my estimation hacks are hacks no matter where they are, and I’d rather put the good and true css in the main stylesheet and the bugbusting version for IE in a separate and easily findable area. This will, hopefully, futureproof my sites in a better way, and allow me latitude if IE8 either gets it right or, as is sadly to be expected, introduces a new crop of bugs to the old, since it will allow me to correct the conditional comment call to “if lte IE 7″ and feed IE8 its own bugbuster stylesheet. It was not fun going back into some of the old sites and fixing for IE7, even though I was more or less prepared. Anything I can do to make a future IE8 transition easier will be a GOOD thing, especially since I’ll have that many more sites in my portfolio by then, and that many more clients to look out for. […]