0

I have the following stylesheet inside the HEAD piece of my website:

<!--[if !IE]-->
<link rel="stylesheet" href="theStyles/defaultStyle.css" type="text/css" charset="utf-8" />
<!--[endif]-->
<!--[if IE]>
<link rel="stylesheet" href="theStyles/defaultStyle_ie.css" type="text/css" charset="utf-8" />
<![endif]-->

I am running IE version 10 but for some reason it is reading the non IE stylesheet. Any idea how to fix it? Do I have to be specific in the IE condition?

I looked in the developer tool, and only the NON IE version has been loaded...

Ended up using this:

<script type="text/javascript">
if (window.clipboardData)
     alert("You are using IE!");
else
     alert("NON IE");
</script>
Si8
  • 8,578
  • 20
  • 88
  • 201
  • No questions on IE. They can do what they want or ignore what they want. That's the sad reality. – Esser Feb 10 '14 at 15:51
  • 1
    @Esser: Don't you just hate free will? Look at Chrome, WebKit and Blink, adding features as and when they want then trying to shoehorn them into the standards. – BoltClock Feb 10 '14 at 15:52
  • possible duplicate of [How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?](http://stackoverflow.com/questions/9900311/how-do-i-target-only-internet-explorer-10-for-certain-situations-like-internet-e) – cimmanon Feb 10 '14 at 16:14

2 Answers2

5

Per Microsoft:

As of Internet Explorer 10, conditional comments are no longer supported by standards mode. Use feature detection to provide effective fallback strategies for website features that aren't supported by the browser.

and

Support for conditional comments has been removed in Internet Explorer 10 standards and quirks modes for improved interoperability and compliance with HTML5. This means that Conditional Comments are now treated as regular comments, just like in other browsers. This change can impact pages written exclusively for Windows Internet Explorer or pages that use browser sniffing to alter their behavior in Internet Explorer.

j08691
  • 190,436
  • 28
  • 232
  • 252
  • So how do I rewrite my code to make sure for ANY version of IE it takes the `_ie` css and anything else use the standard css file? – Si8 Feb 10 '14 at 15:56
  • This JavaScript related question may help you: http://stackoverflow.com/questions/9900311/how-do-i-target-only-internet-explorer-10-for-certain-situations-like-internet-e – j08691 Feb 10 '14 at 15:57
  • I updated my question with a solution I am using... Is it sufficient enough? – Si8 Feb 10 '14 at 16:08
  • Looks like a potential, albeit not widely used, solution. If it works for you then it's fine. – j08691 Feb 10 '14 at 16:13
  • You should not need to give IE a different stylesheet. If it works in Chrome & firefox it should work in IE, unless you are using vendor specific prefixes, etc. – Chris Love Feb 12 '14 at 01:56
1

Only allow the IE style sheet within the conditional comments for IE. Your regular style sheet does not need the conditional comments. It should read as follows:

<link rel="stylesheet" href="theStyles/defaultStyle.css" type="text/css" charset="utf-8" />

<!--[if IE]>
<link rel="stylesheet" href="theStyles/defaultStyle_ie.css" type="text/css" charset="utf-8" />
<![endif]-->
Nina Morena
  • 245
  • 1
  • 7
  • 17
  • It does, otherwise IE will try and read the regular style sheet which is not what the OP wants. The whole point of the question is to try and prevent it from ever reading it altogether regardless of version. – BoltClock Feb 10 '14 at 15:53
  • I looked in the developer console, and only the NON IE version is loaded... weird – Si8 Feb 10 '14 at 15:54