If you are an active web developer, you have likely been plagued by Internet Explorer’s Compatibility View button. I have seen so much poor advice about disabling this feature in IE7+. Post after post after post people suggest forcing a specific version for emulation. Haven’t we all learned that allowing IE to dictate how we code a page is a BAD idea?
If you properly code your pages to use standards and a proper document type definition or <!DOCTYPE>, why does IE persist in not doing what it’s told and letting visitors make potentially baddecisions. A user can accidentally click the Compatibility View button or have compatibility mode always enabled by default (OMG!). If you want to make sure IE or the user doesn’t dictate how you code, or how the layout is butchered by compatibility view, add the following to your <head> section…
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Microsoft indicates that “edge” tells IE8 to use it’s highest compatibility mode available. It should be safe to assume future flavors of IE willk handle it the same way. Thought this is Microsoft we are referring to, so it’s likely to change even thought it is their own browser-specific setting. When will they learn?
I cannot say how much I hate adding extra code to my pages just so a browser will do what it should on it’s own. On 99% of the sites I worked on recently, I use the following <!DOCTYPE> definition…
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Give it about another year when HTML 5 finally takes hold and it will simply become…
We of course cannot do that until IE6, IE7, IE8 and the upcoming IE9 (assuming it will not properly support HTML5 either) have less browser ubiquity. Most open source browsers and Apple products already support HTML5, so now the waiting game begins while we hope M$ developer get off their butts and write a browser that works how it is supposed to in the first place.
If you are considering emulating an earlier version of IE such a IE5, IE6 or IE7, you should be swiftly dealt with. Just bite the bullet, learn the standards, code to a specific <!DOCTYPE> and break free of “quirks mode” and all the other crap Microsoft keeps throwing our way.