How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?-Collection of common programming errors
Internet Explorer 10 does not attempt to read conditional comments anymore. This means it will treat conditional comments just like any other browser would: as regular HTML comments, meant to be ignored entirely.
Note, however, that conditional compilation in JScript is still supported, as shown in the comments as well as the more recent answers. It’s not going away in the final release either, unlike jQuery.browser
.
If you really must target IE10, either use conditional compilation, or – better yet – use a feature detection library such as Modernizr instead of browser detection. Pretty cumbersome, but remember that IE10, as a modern browser that’s highly conformant to today’s Web standards, is designed such that you shouldn’t have to set aside special code for it, i.e. it’s supposed to resemble other browsers in terms of behavior and rendering.1
1 And I may be biased when I say this, but it sure as hell does. If your code works in other browsers but not IE10, the odds that it’s an issue with your own code rather than IE10 are far better than, say, 3 years ago, with previous versions of IE.
Of course, while Microsoft has been doing a fantastic job with standards lately, not everyone is perfect, and we all have some old habits and quirks which we know will never quite go away… but I’m more than willing to give Microsoft the benefit of the doubt here. Again, I may be biased, but let’s be real: who’s to say you’re not?