IE10 Conditional Comments

Let me start by saying that I was very excited by IE10. Internet Explorer 10 was supposed to be the premier IE web browser. Microsoft was so confident that they created a browser that could meet modern standards that they dropped conditional comments in IE10. If you don’t know anything about developing for IE, just know that it sucks; it was, however, aleviated some by conditional comments that allowed for custom styles/js/whatever for IE versions. My first time working with IE10 I was made harshly aware that conditional comments no longer work. What’s worse, my site that functioned and looked great in IE9 no longer functioned in IE10. How does this happen?

The more I work with IE10 the more issues I find with it, Microsoft needs to bring conditional comments back. Until then, however, there is a simple script you can stick in your javascripts that will identify when IE10 is being used so that you can target it in your css or javascript.

The javascript:

// Add IE10 class to IE10
// $.browser requires jquery < 1.9
// $.browser can be used in jquery > 1.9 with plugin
if ($.browser.msie && $.browser.version === 10) {
  $("html").addClass("ie10");
}

It is sad that we must do this for a supposed modern browser; nevertheless, I hope this helps for when you have to work with IE10.