Reputation: 1670
I was wondering when I put my browser in compatibility mode, how does it know what setting to use from the header tags found in the document. If we have logic for all versions back to EI7, will it use the furthest back? So in this case, it chooses 7 in comp mode, but if we only offered back to IE8, then it would choose IE8 for that instance? So the question is, why does IE 11 compatibility mode set it to IE7 standards according to my debugger in IE? If I remove the [if IE7] code snippet, will it then set it to IE8 standards in the browser? We just quit supporting IE7 so am why I am asking this.
[if IE 7 ]> <html class="ie7"
[if IE 8 ]> <html class="ie8"
[if IE 9 ]> <html class="ie9"
Upvotes: 0
Views: 252
Reputation: 3285
In addition, the way you view your pages also affects the document mode.
x-ua-compatible
directive takes precedence; depending on the setting, the <DOCTYPE>
may also have an impact.For best results:
<DOCTYPE>
directive. x-ua-compatible
meta with content set to IE=edge
.Hope this helps...
-- Lance
Upvotes: 1
Reputation: 5022
The code you've quoted in the question does NOT tell IE what mode to use. What this code does is look at the mode that IE is already in, and react accordingly.
Therefore, the answer to your question is: No: Removing the IE7-specific block from this code will not stop IE going into IE7 mode.
If you want to force IE to go into a specific mode, the code you need to use is the X-UA-Compatible
meta tag.
You need a line near the top of you HTML that looks like this:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Putting edge
in the content tells IE to use it's best available mode (so IE11 will be in IE11 mode). If you want a specific IE mode, then put IE8
or similar instead of edge
.
Upvotes: 1