We use conditional comments to target specific versions of Microsoft’s Internet Explorer browser (MSIE), mainly through our ie_conditional_tag. This returns a block of markup that applies various class names to the tag, like this:
<!DOCTYPE html> <!--[if lt IE 7]><html class="ie ie6 some-custom-class"><![endif]--> <!--[if IE 7]><html class="ie ie7 some-custom-class"><![endif]--> <!--[if IE 8]><html class="ie ie8 some-custom-class"><![endif]--> <!--[if IE 9]><html class="ie ie9 some-custom-class"><![endif]--> <!--[if gt IE 9]><html class="ie some-custom-class"><![endif]--> <!--[if !IE]><!--><html class="some-custom-class"><!--<![endif]--> <head> <title>New HTML5 page</title> </head> <body> <!-- your content --> </body> </html>
This lets us target older versions of MSIE specifically to improve our experience across browsers. Microsoft’s development team intends to remove "the less-successful legacy features" in Internet Explorer 10, and one of those is conditional comments.
The main reason for conditional comments and targeted styles has been the slow pace at which enterprise IT departments upgrade their systems. There are just a lot of users on older browsers, and by ignoring them, we are ignoring customers. That may be considered a good thing for certain markets, but not everyone has that luxury
Playing Nice While Looking Forward
Internet Explorer 9 is already a very robust browser and has support for many of the cutting edge elements in HTML and CSS that we’ve started to explore. Microsoft has also announced that it will begin doing automatic updates on browsers in Windows XP, Vista, and 7
This doesn’t mean that our conditional tag won’t continue to do what it’s always done. Older browsers will self-register and add the class to the tag. And by writing valid markup, we can avoid a lot of the issues between browsers. For those of us who still have to make MSIE6 and it’s younger cousins work, there’s a lot of documentation out there to get us there.
Have fun in the trenches!