Casey ScriptFu Pharr
Casey ScriptFu Pharr

Reputation: 1670

IE issue with compatibility modes

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

Answers (2)

Lance Leonard
Lance Leonard

Reputation: 3285

In addition, the way you view your pages also affects the document mode.

  • If you view a page on the Internet (or through a local web browser), the page opens in the Internet zone. In this case, the x-ua-compatible directive takes precedence; depending on the setting, the <DOCTYPE> may also have an impact.
  • If you open the page using the File menu, from File Explorer, or from a network path, the page opens in the Intranet zone. By default, this means your page opens in IE7 compatibility mode, though that can be changed through settings.
  • Apps hosting the webBrowser control default to IE7 unless you override that using a registry change. (Note, it's currently unclear whether this is supported in Windows 10).

For best results:

  1. Use the HTML5 <DOCTYPE> directive.
  2. Use an x-ua-compatible meta with content set to IE=edge.
  3. View local pages through a local webbrowser.
  4. Code for HTML5, detect features, provide graceful fallback, and worry less about individual differences between individual browsers.

Hope this helps...

-- Lance

Upvotes: 1

Simba
Simba

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

Related Questions