1. Computing

Discuss in my forum

How to Force Internet Explorer to View a Page in Compatibility Mode (or Not)

Use DOCTYPE and Meta Tags to Choose the IE View Mode

By

The easiest way to tell Internet Explorer to use compatibility view is to either leave out the DOCTYPE on the web page entirely or to place anything above the DOCTYPE (including an XML declaration or comment).

Here are some examples. Each block of HTML is the entire web page document.

Standards View

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>This page is NOT Rendered in Compatibility View</title>
  </head>
  <body>
    <h1>This page is NOT Compatibility View</h1>
  </body>
</html>

Compatibility View

<html>
  <head>
    <title>This page is NOT Rendered in Compatibility View</title>
  </head>
  <body>
    <h1>This page is NOT Compatibility View</h1>
  </body>
</html>

Standards View

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>This page is NOT Rendered in Compatibility View</title>
  </head>
  <body>
    <h1>This page is NOT Compatibility View</h1>
  </body>
</html>

Compatibility View

<?xml version="1.0" encoding="UTF-8">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>This page is NOT Rendered in Compatibility View</title>
  </head>
  <body>
    <h1>This page is NOT Compatibility View</h1>
  </body>
</html>

Note, that last example should load as standards view in XHTML mode. But Internet Explorer interprets that XML declaration as requiring compatibility view.

Using HTTP Headers to Force Standards View in Internet Explorer 8 and Above

You can also use meta tags to force standards mode. The X-UA-Compatible meta tag tells Internet Explorer what view mode to use or emulate.

By setting this meta tag, you tell IE to use standards mode even if there are comments or an XML declaration above the DOCTYPE. You determine what version of Internet Explorer can best view the page, and then set the meta tags to define that version.

IE 7:

<meta http-equiv="X-UA-Compatible" content="IE=7">

IE 8:

<meta http-equiv="X-UA-Compatible" content="IE=8">

IE 9:

<meta http-equiv="X-UA-Compatible" content="IE=9">

If a customer comes to a page with a view mode higher than it supports (e.g. an IE 7 browser viewing a page asking for IE8 view mode), it will ignore the tag and render the page the the mode it would have without the tag.

  1. About.com
  2. Computing
  3. Web Design / HTML
  4. Testing Your Web Pages
  5. Web Browsers
  6. Internet Explorer
  7. How to Force Internet Explorer to View a Page in Compatibility Mode (or Not)

©2014 About.com. All rights reserved.