CSS Compatibility Mode Hack for IE8
Early versions of Microsoft Internet Explorer didn't adhere strictly to Web standards, causing designers problems with cross-browser compatibility. Today's IE is much more standards-compliant, but because many websites were designed using CSS "hacks" for those early versions, Microsoft had to devise its Compatibility Mode, also known as Compatibility View. This mode enables IE8 and later to accurately render those sites.
-
Compatibility Mode
-
By default, IE8 and later versions render webpages according to modern standards, so that most sites can be written with standards-compliant HTML and CSS. Ironically, this means that older sites may not display in current IE versions without either recoding or the addition of a browser feature that renders those sites the same way previous versions did. Microsoft added such a feature, Compatibility Mode, to IE8. If the viewer clicks a button on the browser or the webmaster adds a single line of code to a page, IE8 and later versions will use the older version of the rendering engine to display the page.
Compatibility Mode Tag
-
The X-UA-Compatible metatag signals to IE that the content on that page is compatible with a specific version of the browser. To add the metatag to a page, insert the following text to the <head> section, above all other tags except the <title> tag and other metatags:
<meta http-equiv="X-UA-Compatible" content="IE=5" />
The version of IE in the metatag should correspond to the browser version most compatible with the page. "IE=5" represents both IE5- and IE6-compatible code, "IE=7" indicates a page written for best results with IE7, and "IE8" would force the browser to use current standards.
-
Compatibility View Button
-
If a site is coded for a previous IE version but doesn't carry the X-UA-Compatible metatag, a visitor using IE8 or later will see a "broken page" icon in the browser's address bar. Clicking that icon will trigger Compatibility View and render the page appropriately. IE also maintains a list of sites for which Compatibility View was used, so the visitor doesn't have to click the button on each visit. This also means that a page updated after the visitor has triggered Compatibility View should use the metatag to indicate that it's now standards-compliant.
HTTP Header
-
If an entire site is compatible with a specific version of IE, you can also use an HTTP header to communicate that fact to the browser. The header takes this form:
X-UA-Compatible: IE=EmulateIE7
Insert the appropriate IE version for the site, just as you would in the metatag. If you update your site to be standards-compliant, you can also update the HTTP header with "IE8" so that repeat visitors using IE8 and later don't continue to use Compatibility View when they visit.
-