Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will targeting IE8 with conditional comments work?

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.

like image 286
Devon Avatar asked Oct 03 '08 16:10

Devon


People also ask

Are HTML conditional comments compatible with Internet Explorer?

HTML Conditional Comments: Are They Compatible With Internet Explorer? HTML conditional comments are elements that can only be only used within certain Internet Explorer versions. Moreover, the conditional comments in HTML documents are used to provide specific HTML content for older IE versions, and also link to certain files.

How to include CSS properties and rules into Internet Explorer?

One of the most common ways to include CSS properties and rules into Internet Explorer is by using conditional HTML comments. In the previous section, we exemplified what is the easiest way to create a conditional comment syntax, and in this section of the article, we are going to show you how you can make it more complex.

Is IE11 a big problem for You?

This is a huge problem for anyone using IE11 in different modes (IE7, IE8, and IE9). But first, let’s clear something up. Nobody should depend on IE10 or IE11’s emulation of older versions of IE.

What are the rules for comments on the website?

Comment Rules: Please use a real name or alias. Keywords are not allowed in the "name" field and deep URLs are not allowed in the "Website" field. If you use keywords or deep URLs, your comment or URL will be removed. No foul language, please. Thank you for cooperating. Markdown in use!


2 Answers

One thing to note:

It does work, BUT if you are loading the page/site local network (e.g. Intranet) it will load in IE7 mode by default! (update - localhost[*] is a special case, that does render in standards mode)

This goes against MSFT's original statement of going STANDARDS by default.

e.g.

http://127.0.0.1/mysite/mypage.php  <-- IE8 by default (updated!)
http://localhost/mysite/mypage.php  <-- IE8 by default (updated!)
http://machinename/mysite/mypage.php  <-- IE7 by default
http://192.168.100.x/mysite/mypage.php  <-- IE7 by default
http://google.com/  <-- IE8 by default

[*] - Scott Dickens [MSFT] noted in a comment here on the IE Blog that localhost was a special scenario in the Intranet (often used to develop Internet sites) thus would render in Standards mode by default.

To test what mode a page in IE8 is really rendering in, you can use check the developer tools or use this bookmarklet code (only works in IE8):

javascript:
var vMode=document.documentMode;
var rMode='IE5 Quirks Mode';
if(vMode==8){
  rMode='IE8 Standards Mode';
} else if(vMode==7){
  rMode='IE7 Strict Mode';
}
alert('Rendering in: '+rMode);
like image 85
scunliffe Avatar answered Oct 23 '22 05:10

scunliffe


It worked for me – both in quirks mode and in standards compliance mode. However, it does not work when switching to IE8 compatibility mode.

like image 34
Konrad Rudolph Avatar answered Oct 23 '22 04:10

Konrad Rudolph