Targeting and filtering IE with relative ease
I just read a blog post by James Scariati regarding a method to target every version of IE from a single stylesheet. The idea was to add a wrapper div with a specific class using conditional comments, allowing you to target IE6 using CSS specificity rather than separate stylesheets. The commenters took it a bit further, and I decided to test out a slight permutation.
<!DOCTYPE html> <html> <head><title>IE Targeting</title></head> <!--[if ! IE]><!--><body class="notIE"><!--<![endif]--> <!--[if IE 6]><body class="ie6"><![endif]--> <!--[if IE 7]><body class="ie7"><![endif]--> <!--[if gte IE 8]><body class="ie8"><![endif]--> <button onClick="alert(document.getElementsByTagName('body').className);">Check it</button> </body> </html>
Thanks to James Scariati for the idea, Greg McAusland for the evolution of it!