Solution 1:

CSS Solution:

If you want to apply only CSS base on browser then you can try:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {  
   /* Put your IE-only styles here. Works for IS 10 & IE 11*/
}

JavaScript Solution:

IE 10 does not support conditional statements.

Conditional statements in Internet Explorer 10.. It will treat conditional comments as regular HTML comments, and ignored entirely.

Use a feature detection library such as Modernizr instead of browser detection.

found a solution on impressivewebs in this comment:

Here is Demo to test

The solution is:

if (Function('/*@cc_on return document.documentMode===10@*/')()) {
    alert('IE 10');
} else {
    alert('Not IE 10');
}

It

  • doesn’t need conditional comments;
  • works even if comment stripping compression/processing;
  • no ie10 class added in Internet Explorer 11;
  • more likely to work as intended with Internet Explorer 11 running in Internet Explorer 10 compatibility mode;
  • doesn’t need standalone script tag (can just be added to other JavaScript code in the head).
  • doesn't need jQuery to test

Solution 2:

I'm surprised that no one has added in a css-only solution. If you just want to use css, then use a statement like this:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {  
   /* Put your IE-only styles here. Works for IS 10 & IE 11*/
}

This way you don't have to rely on jquery, or any html markup. Just post it in the css and you are good to go.

Now, is it a hack? Likely. This depends on using the microsoft high-contrast tag, but since no other browser uses the ms tag then you should be good to go.

Finally, check out these pages for more info:

Blog Post

MS Site on the contrast tag

Solution 3:

IE 10, 11 and upward no longer support conditional comments.

See this answer: https://stackoverflow.com/a/22187600/1498739