Take the 2-minute tour ×


I tried this, but it doesn't work:



share|improve this question
I think a better question would be : How do I get this CSS to look the same on both browsers ? –  BentOnCoding Mar 28 '12 at 2:51
IE10 PP4 Still supports the @cc_on statement. So, to detect whether IE10 is supported or not, you can use the following code: <!--[if !IE]><!--><script>if(/*@cc_on!@*/false){document.documentElement.className+=' ie10';}</script><!--<![endif]-->. (I posted this as a comment, since IE is still in development, so it's not known whether the final release supports this feature as well) –  Rob W May 13 '12 at 11:14
@RobW - Your example code will be wrong once ie11 is out. Improved version: <script>if(Function('/*@cc_on return document.documentMode===10@*/')()){document.documentElement.className+=' ie10';}</script> Improvements: doesn't need conditional comments; works even if comment stripping compression/processing; no class added for ie11; will work with ie11 running in ie10 compatibility mode; doesn't need standalone script tag (can just be added to other javascript in head). –  robocat Dec 6 '12 at 23:21
Example of the above code snippet: jsbin.com/upofoq/2 –  robocat Dec 6 '12 at 23:29
A more generic solution is: if(document.documentMode) document.documentElement.className+=' ie'+document.documentMode+'mode'; - which solves 90% of issues (sometimes compatibility modes fail, in which case you need another level of fix on top of that). –  robocat Dec 6 '12 at 23:40

23 Answers 23

up vote 45 down vote accepted

Perhaps you can try some jQuery like this:

if ($.browser.msie && $.browser.version == 10) {



share|improve this answer
I am not sure about you guys but I need to use == '10.0' for it to work –  lulalala Jan 8 '13 at 10:06
Warning: jQuery.browser is no longer available in the current version of jQuery (1.9) without a plugin. blog.jquery.com/2013/01/15/… –  dave1010 Jan 18 '13 at 11:01
I would recommend: if (jQuery.browser.msie && jQuery.browser.version < 10) { // do what you will here } Note the verion < 10 to detect older versions of IE. IE10 and above works fine with all my CSS3, HTML5, jquery, etc. –  Dan Mantyla Mar 12 '13 at 20:45
@dan because conditional comments work in all IE browsers less than 10 use them instead of cluttering your JS for all browsers. Just say <!--[if lte IE 9]> and you can target all IE versions less than 10. No JS required. –  htech Apr 28 '13 at 1:25
@Marc-AndréLafortune raises a good point. As a rule of thumb you should always use the === operator and not ==. When writiing javascript you need to be mindful of this. stackoverflow.com/questions/359494/… –  Stewart Nov 7 '13 at 0:32


The solution is:

    document.documentElement.className+=' ie10';


  • doesn’t need conditional comments;
  • works even if comment stripping compression/processing;
  • no ie10 class added in Internet Explorer 11;
  • doesn't need jQuery to test
share|improve this answer
@dave1010 User agents can easily be spoofed. Conditional comments are only supported by the JScript engine, which is only available in IE4+ (including 10). –  Rob W Feb 6 '13 at 18:08
@dave1010 Writing a working parser which does what you're describing is difficult and extremely unlikely. Anyone who deliberately creates and installs such an extension is most likely intending to "act like" IE (perhaps for automated testing purposes on non-Windows environments?). 100% trust is never guaranteed in browsers, but you can get sufficiently close. Conditional comments are a highly reliable way to detect the JScript engine, which happens to be used by IE. –  Rob W Feb 8 '13 at 14:20
only disadvantage I can see is that it requires js, which conditionals didnt –  James Westgate Mar 21 '13 at 9:23
This should be the top answer, and the JS requirement should be moot for IE10 users - if JS is disabled it will probably just be the NoScript addon. I think we need more public education about the sheer stupidity of NoScript (as opposed to sane addons like AdBlock or Ghostery). –  iono Apr 17 '13 at 4:27
I'd suggest using the alternative code provided by the author: if (/*@cc_on!@*/false && document.documentMode === 10) {} which gets around eval warnings in linting programs. –  ajbeaven Oct 16 '13 at 22:58


This CSS solution will target Internet Explorer 9, 10 and 11:

    /* Enter CSS here */

Moving Internet Explorer specific CSS into @media blocks

share|improve this answer
Nice to see another method. I didn't know there were so many at first. –  trusktr Feb 17 '13 at 8:57
Somebody give this guy a medal –  Ahmad Alfy Nov 5 '13 at 12:30
This should be the accepted answer! –  Serj Sagan Nov 28 '13 at 0:10
You are my hero! Just a note, This also fixed some stuff messed up in IE11 –  locrizak Dec 2 '13 at 16:49
This affects also IE11 - so if you're looking for solution to target only IE9/10 this one won't work :-( –  Lukasz Lenart Mar 13 at 9:15




If you do have a legitimate reason to be targeting certain browsers, by all means use the alternatives that exist. I'm just saying that you're going to be much more hard-pressed to find such a reason today than what it used to be, and it's really just not something you can rely on.



share|improve this answer
Chhhh, yeah, IE10 still lags far behind webkit and gecko. I have some CSS looking all nice in webkit and hideous in IE10. If I can't find a way to selectively apply the styles, then I'll have to abandon such styles. :( –  trusktr Mar 28 '12 at 2:34
@BoltClock: can't stop laughing when thinking at IE as a browser "designed such that we shouldn't have to set aside special code for it". –  Marco Demaio Sep 4 '12 at 14:49
@trusktr if you code it well then it will look good in all the latest browsers. –  Klevis Miho Jan 3 '13 at 14:40
@KlevisMiho Not true, Chrome and Firefox support features that IE doesn't have, even if coded well. If you mean "use only common features" then that's not quite the same as "code well". –  trusktr Jan 3 '13 at 21:12
@Dan Mantyla: In that case, <!--[if !IE]><!-->stuff you don't want IE9 and below to see<!--<![endif]--> –  BoltClock Mar 12 '13 at 20:43

A good place to start is the IE Standards Support Documentation.

Here is how to target IE10 in JavaScript:


Here is how to target IE10 in CSS:


In case IE11 needs to be filtered via CSS, see another question: How to write a CSS hack for IE 11?

share|improve this answer
Nice one. This question has had perhaps the most diverse set of answers compared to all my other questions. –  trusktr Jul 2 '13 at 3:08
i like this way –  Alex Nov 12 '13 at 9:39
Your CSS solution also affects IE11 :\ –  Lukasz Lenart Mar 13 at 10:10
@LukaszLenart Good point. Link added to IE11 filter. –  Paul Sweatte Mar 13 at 17:47
This is a great way of doing it! –  egr103 Sep 11 at 11:02



Check out my blog post: http://mattstow.com/layout-engine.html and get the code on GitHub: https://github.com/stowball/Layout-Engine

share|improve this answer
This is brilliant and by far the best solution I've tried. I just implemented this in a Drupal site I'm developing and it works as advertised. Thank you! –  Danny Englander Sep 6 '13 at 21:45
Excellent, clean, lightweight solution - nice work :-) –  mindplay.dk Jan 22 at 15:16

Both solutions posted here (with slight modifications) work:





.ie10 .myclass1 { }

And voilà! - other browsers stay intact. And you don't need jQuery. You can see the example how I implemented it here: http://kardash.net.

share|improve this answer

You can use PHP to add a stylesheet for IE 10


share|improve this answer
It doesn't make sense to upper the string as stripos is not case sensitive ;) –  mgutt May 6 '13 at 21:51
Just changed that ;) –  Lenny Bruyninckx Sep 19 '13 at 13:41
I always tempt for this, but then remember that it breaks when there is a cdn/cache/proxy at front end. –  Johan Dec 8 '13 at 18:40




share|improve this answer
what are the ``!!` for ? –  Francisco Corrales Morales May 22 at 2:23
String.match() will return an array for a match or null if it doesn't. !(String.match()) makes it return false for a match or true for no match. !(!(String.match())) makes it return true for a match or false for no match. !(!(something)) or just !!something therefore converts anything to a boolean true/false. stackoverflow.com/questions/784929/… –  dave1010 May 22 at 13:48
@FranciscoCorralesMorales Oh the number of times I've been asked that when my code is under scrutiny. :) As an expansion to dave1010's great comment, it can be used to coerce 'truthy' or 'falsy' values into an intrinsic boolean value, e.g. var name = 'me', hasName = !!name;. –  WynandB Jul 10 at 5:40


      @if (@_jscript_version == 10)
</script >
share|improve this answer
Cool. Could you add a little info on what those @statements are? –  trusktr Jan 29 '13 at 3:19


if (document.body.style.msTouchAction != undefined) {
  document.body.className = 'ie10';

CSS properties


  • msTouchAction
  • msWrapFlow
  • msWrapMargin
  • msWrapThrough
  • msScrollLimit
  • msScrollLimitXMin
  • msScrollLimitYMin
  • msScrollLimitXMax
  • msScrollLimitYMax
  • msFlexbox
  • msFlex
  • msFlexOrder

Test page

I've put together a test page with all properties on CodePen.

share|improve this answer


<script type="text/javascript">
if (window.clipboardData)
            alert("You are using IE!");
share|improve this answer
Very simple... Thanks :) –  SiKni8 Feb 10 at 16:05
-1: but what about versions ? how can you tell which version is ? –  Francisco Corrales Morales May 22 at 2:24


var isIE = false;
if (window.navigator.msPointerEnabled) {
    isIE = true;

Only true if > IE9

share|improve this answer


share|improve this answer

I just wanted to add my version of IE detection. It's based on a snippet found at http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/ and exteded to also support ie10 and ie11. It detects IE 5 to 11.


var isIe = (function(){
    var undef,
    while (
    return v > 4 ? v : undef;
share|improve this answer

With JavaScript:


Work for all IE.

IE08 => 'Trident/4.0'

IE09 => 'Trident/5.0'

IE10 => 'Trident/6.0'

IE11 => 'Trident/7.0'


share|improve this answer



    if (document.documentMode===10){
        document.documentElement.className+=' ie10';
    else if (document.documentMode===11){
        document.documentElement.className+=' ie11';


share|improve this answer
The (gt IE 11) bit is completely unnecessary. You may as well just do <!--[if !(IE)]<!--> instead. –  BoltClock May 22 at 3:06

Here is how I do custom CSS for Internet Explorer:

In my JavaScript file:

function isIE () {
      var myNav = navigator.userAgent.toLowerCase();

            if(var_isIE == 10){
            if(var_isIE == 8){


.ie10 .some-class span{
.ie8 .some-class span{
share|improve this answer

Check out http://suhasrathod.wordpress.com/2013/04/29/ie10-css-hacks/

       /* IE10-specific styles go here */
share|improve this answer




share|improve this answer



Use jQuery (which deprecated .browser in favor of user agents in 1.9+, see http://api.jquery.com/jQuery.browser/) to add an .ie class:

// ie identifier
$(document).ready(function () {
  if (navigator.appName == 'Microsoft Internet Explorer') {
share|improve this answer
"which deprecated .browser in favor of user agents in 1.9+" It doesn't say "in favor of user agents" - whatever that means - it says in favor of feature detection. –  BoltClock May 22 at 3:04



Derived from http://www.paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither

share|improve this answer
I didn't -1 your answer but the link seems somewhat outd-eight-ed. It's also worth noting that OP intended to target IE10 and IE10 only. Regardless, your code snippet won't work for either IE10 and above or any other non-IE browser, because conditional comments are only supported in IE5 up to IE9. –  WynandB Jul 10 at 6:20

modern solution for css

  your-style: here;
share|improve this answer

Your Answer


