Alex Rivera | Logout

Will targeting IE8 with conditional comments work?

Asked 2008-10-03T16:13:26.820
18

When IE8 is released, will the following code work to add a conditional stylesheet?

<!--[if IE 8]>
  <link rel="stylesheet" type="text/css" href="ie-8.0.css" />
<![endif]-->

I've read conflicting reports as to whether this works with the beta. I'm hoping someone can share their experience. Thanks.

Edit
Report

2 Answers

0

Thank you for your help. I've discovered the solution, apparently the problem was having each style sheet use its own title attribute. Once I took the title off all but the main style sheet, no prob.

This is a weird issue unique to IE8 - and although I've been told its supposed to work that way, something to do with "Stylesheet Preference" - it only serves to create problems since the solution requires you remove the title which could be helpful when scripting, etc - when you need to call the style sheet.

In any case, not sure if this is a bug, or its supposed to be that way, but I hope Microsoft investigates further.

Thanks

answered 2009-08-07T19:29:18.943
0

Why even bother writing a separate stylesheet for IE8?

If you've already debugged for IE7, you can force IE8 into compatibility mode, and thus display your code as though IE8 were IE7.

All you gotta do is put this RIGHT BELOW the opening head tag. Anywhere else and it won't work.

And then that's a half hour or so less work on average per project, no intense debugging for IE8 needed!

Even Msn.com does this - kind of ironic, eh?

Wrote a blog post about it recently: http://blog.sankhomallik.com/2009/11/16/stop-wasting-time-debugging-on-ie8-when-you-dont-have-to-or-get-ie8-to-behave-like-ie7/

answered 2009-11-16T21:52:14.557

Your Answer