As of Internet Explorer 10 conditional comments are no more, but what if you have an edge case where you really need to specifically target IE10 or IE11? For example an .ie10 or .ie11 css class at the top level would still be really useful, however without conditional comments we need an alternative.

The user agent string for IE10 is:

Therefore we can detect IE10 by sniffing the user agent string in javascript, then we can add a CSS class to the HTML element using jQuery.

If we want to target IE11, we can check for the presence of the MS Input Method Editor API, this will return true for IE11 and false on Edge and all other IE browser versions.

 

Snippet

LEAVE A COMMENT

Notify of
avatar
wpDiscuz