Unpacking Internet Explorer 8's multiple rendering modes

Internet Explorer 8 is going to be the most standards-compliant IE yet, but it's going about it in a way that has some people scratching their heads. With Internet Explorer 8, you have a choice in standards compliance modes. Sound oxymoronic? Shouldn't there be one standards mode by default? Heck, shouldn't the only mode be standards mode? Ah, idealism.

One of the nastier things about being a web developer, I'm told, is the existence of Internet Explorer. Massively popular, but full of "quirks," coding around IE can be a real pain. When IE7 shipped, many web developers recoiled in horror as sites that worked fine in IE6 broke.

The problem, as is so often the case, is backwards compatibility. IE5.5 (and below) was decidedly nonstandard in its rendering behavior. Hundreds of millions of web pages were written to look "right" in IE5.5's broken rendering. The result was something of a quandary for Microsoft when it came to release IE6. They wanted to improve the standards conformance in IE6, but couldn't afford to break pages dependent on the older behavior.

The solution was the "doctype switch". The doctype switch allowed IE6 to support both the old IE5.5 behavior—"quirks mode"—and new, more standards-conforming behavior—"standards mode." Doctypes are an optional part of HTML pages, which specify which version of the HTML spec a page is using. In the olden days of the web, most web pages didn't bother to specify—they barely heeded the mandatory parts of the standards, let alone optional parts. So the presence of the doctype could be used to pick between modes—if someone used a doctype, they probably knew what they were doing, and wanted "standards mode." No doctype (or a doctype specifying an old version of HTML) and they were probably assuming nonstandard behavior, and "quirks mode" would be picked.

At least, that was the theory. The thing about IE6's "standards mode" is that it wasn't all that standard. Although it fixed some of the bigger issues IE5.5 had, it still had plenty of its own. With IE7, MS tried to fix a few more of the nonconformance problems. The intent was to keep "quirks mode" the same as it always had been, and to further improve "standards mode." What the company discovered when it did this was that people using the doctype weren't actually expecting "standard" behavior. Rather than writing pages to target the HTML specifications, these pages were written to work with IE6's still-not-standard-but-better-than-before behavior. So, they didn't work with full-blown "quirks mode" rendering—but they didn't work with 100%-standard rendering either.

Sometimes this was deliberate—developers taking standard pages (that work properly in, say, Safari) and adding hacks to them in order to get an acceptable appearance in IE. Other times, it was accidental; developers added the doctype because it was fashionable to do so, or because their design tools added it automatically, without fully understanding the consequences of the switch. Whether by accident or by design, most pages using "standards mode" are expecting IE6's own unique take on "standards mode", and not true standard behavior.

The upshot of this is that IE7 broke pages that used to work in IE6. Both business-critical intranet apps and the Web in general stopped working—not normally fatally, but enough to throw out layouts and make pages look wrong. This undoubtedly hurt IE7's uptake, and that has Microsoft concerned. IE7 is finally going to be put out as an automatic update in the next few weeks, and the reason it has taken so long is this reluctance from businesses. If the standardization changes were made to "standards mode," using the doctype switch, all those pages demanding not-really-standards-mode will break. That's a lot of pages, and they'll break even more badly than they broke with IE7.

Which brings us to IE8. With IE8, Microsoft wants to further improve the standards conformance of the browser, to bring it up to a level that's comparable to Firefox 3, Opera, and Safari. Experience with IE7 and the doctype switch leaves the software giant concerned that further fixes to "standards mode" will, in the company's words, "break the Web."

The IE8 solution: add another layer

When IE8 eventually ships, it will have three rendering modes, two of which are the already familiar "quirks mode" and "(not so) standards mode." In an IE team blog entry, IE Platform Architect Chris Wilson revealed a third mode that can be invoked by developers:

"Quirks mode" remains the same, and compatible with current content. "Standards mode" remains the same as IE7, and compatible with current content. If

you (the page developer) really want the best standards support IE8 can

give, you can get it by inserting a simple <meta> element.

This third mode will use a <meta> tag to specify that a page should use the behavior of a specific browser version. To get IE8 really-standard-this-time-we-mean-it behavior, a page will include an element like <meta http-equiv="X-UA-Compatible" content="IE=8" />. That says that a page should use IE8's behavior—and should use it even in IE9, IE10, or any future version. The first two modes will continue to use the doctype switch to choose between them.

This should solve the problem that so hurt IE7. The developer expectation that IE's "standards mode" should remain the same indefinitely should be met. As long as a page works in IE7, it should continue to work in the same way in IE8.

The idea for this new tag was not developed by Microsoft in isolation. The company worked with the Web Standards Project (WaSP) to devise this mechanism, to allow the existing web to work, and the future web to be standards compliant. Aaron Gustafson, one of the members of the WaSP-Microsoft task force who devised this scheme, published an article on A List Apart further detailing the specifics of the declaration.