2

I'm using the following IE conditional statement to load an IE-specific stylesheet. The statement works in IE 7, 8 and 9 Compatibility View. However, when I viewed the page in plain IE 9, the page was empty. I inspected it in developer tools, and it appears as though the conditional statement never closes, effectively commenting out the rest of the page.

<!--[if lt IE 9]><link xmlns="" rel="stylesheet" href="http://colum.edu/Site_Files/localist/css/ie.css" /><[endif]-->

After a decent amount of hair-pulling, I finally figured out that if I add a space before the brackets for the conditional comment, it comment works in IE 9:

<!-- [if lt IE 9]><link xmlns="" rel="stylesheet" href="http://colum.edu/Site_Files/localist/css/ie.css" /><[endif]-->

The only difference is that there is a space between comment and the conditional statement...

<!--[if lt IE 9]>   vs   <!-- [if lt IE 9]>

I can't figure out why on earth this is happening. Again, it only happens is "Browser Mode: IE9" not "Browser Mode: IE9 Compatibility view" with "Document Mode: IE9 standards". (I realize that the simplest solution is to add the space. However the real page lives on a hosted service, and I'm limited in what I can edit.) Anyways, here are some examples:

Not working: http://dev.ashramcreative.com/ccc/localist/ie9.html

Working: http://dev.ashramcreative.com/ccc/localist/ie9-space.html

dbhynds
  • 39
  • 1
  • 4
  • Can anyone else even duplicate this? – dbhynds Mar 29 '12 at 15:16
  • Like Jeffrey said: “in your case it appears as though the should be ”. Thus, your problem description is misleading. The reason why adding the space works is because then it becomes a normal comment. (And this also happens in IE8 and below.) – Komputist Oct 24 '12 at 12:15
  • This question appears to be off-topic because it was caused by a typo – Liam Jul 24 '13 at 08:48
  • I'm experiencing the same issues - how did you fix this? – Mazatec Aug 20 '13 at 09:18

1 Answers1

4

I just ran into the same thing; and adding the space before the conditional fixed IE9 in browser mode.

After reading this post I was able to determine that a meta tag was to blame.

After I corrected the meta tag (in my case meta http-equiv=content-type), IE9 in browser mode worked correctly without the space.

However, in your case it appears as though the <[endif]--> should be <![endif]-->

Community
  • 1
  • 1
Jeff Ayer
  • 74
  • 6
  • Wow. I spent hours staring at the code, trying to figure out what was wrong. Can't believe I missed that. Thanks! – dbhynds Apr 09 '12 at 15:49
  • 1
    Perhap, @dbhynds you should edit your initial post, to signal that you posed an incorrect question. – Komputist Oct 24 '12 at 12:16