Goodbye DOCTYPE switching, hello META targeting
DOCTYPE switching is going to die, replaced by a more flexible and stable alternative. To me the new method makes perfect sense, but there seem to be waves of indignant objection rolling around over the topic at the moment. Me? I think this is the best thing to happen to web standards, ever. Allow me to elaborate on why this is bigger even than the whole revolution efforts of recent years. First, a little background:
What’s going to replace DOCTYPE switching
Beyond DOCTYPE: Web Standards, Forward Compatibility, and IE8 discusses the new method of telling browsers what rendering engine to use on a particular page. Right now, we have two choices - use ‘quirks mode’ which is the rendering behaviour and box model of IE5.5 and earlier, or use Web Standards mode. We do this by including a valid DOCTYPE in our HTML. It’s a switch that tells the browser how to interpret the HTML and CSS content. But, as Eric Meyer spotted too, this is an unsustainable method of controlling what browsers do with the code we give them. That’s because there isn’t one version of ‘Web Standards’ mode, it invariably has limited support, or a few bugs, in each version of a browser. IE6’s ‘Web Standards’ mode was very limited, and very broken. IE7’s was far less limited and not so broken. Which meant that when we told each browser to use ‘Web Standards’ mode by supplying a valid DOCTYPE they both did - IE6 getting it wrong, IE7 getting it (mostly) right. The result was a mess because site’s that rendered properly in IE6’s ‘Web Standards’ mode broke in IE7’s ‘Web Standards’ mode (correctly, however inconveniently).
DOCTYPE switching simply can’t handle multiple ‘Web Standards’ modes, and because each browser engine, and each version of a browser, has it’s own bugs and or limited feature set within it’s own “web standards” mode - you can’t treat it as a level playing field. It becomes a mess.
So the new method is brilliant - a simple meta tag that states what version of which browser the site has been tested in. The idea being that IE8 (and with any luck all newer browsers from all vendors) will look at that and use the render engine that is known to work. So, when IE8 comes out there won’t be any of the problems we saw when IE7 came out - because IE8 will see the meta tag and use the IE7 render engine to display the page.
Why the ruckus?
If a page doesn’t have any version-targting information, then the DOCTYPE will be used as a proxy for version targeting. For example, all the HTML4 and XHTML1 DOCTYPEs will be targeted to IE7 by default. In the future, HTML5 DOCTYPEs might by default be targeted to IE9 or IE10, depending on how things shake out.
Makes sense, it ensures that pages without a meta-tag (which is every page on the web right now) are rendered in a mode most likely to display and behave correctly. This is no worse than if we had only the regular DOCTYPE method. Concerns that in future pages authored for modern browsers will render wrongly because of a missing meta-tag are incorrectly placed. Just as authoring environments now include valid DOCTYPES, in future they will include realistic meta-tags. Thus mitigating the problem. And were anyone to develop a web page in future-land via notepad for example, and not have the META tag, well when they are testing their page the browser will be rendering in a fall-back DOCTYPE induced mode anyway. Basically, it’s impossible to produce a visually broken page because of ignorance, even if you could still produce a tag-soup mess.
Why the new system is a driving force for learning standards
The default behaviour does remove the option of using ‘progressive enhancement’ from us. A method whereby authors write little bits of CSS that are not supported in current browsers, but will be in more modern ones. It means that when the new browsers show up there will be a few minor display flourishes for them to see. Well, that won’t happen any-more unless you specify ‘edge’ in the META tag, because the default treatment is to render as IE7 not IE8. Well so what?
You get to keep progressive enhancement by turning the tag to ‘edge’. So the people that use the technique (used only by standards aware and smart developers, by definition) get to keep the current behaviour of ‘give me the new shiny as soon as you can’. Those that don’t know about the new tag system are not the people who are coding in a ‘progressive enhancement’ style anyway, so there is absolutely no loss there.
Further, I think the new default of ’stay as IE7 when no meta tag found’ will enhance the uptake of web standards. Because every ignorant developer on earth is now going to be permanently stuck with IE7 rendering and behaviour. They will never get to use any of the new-shiny of IE8 and above if they don’t know to include that meta tag. They won’t know to include that meta tag until they go away and learn about web standards.
If I could, I’d have every browser on earth fall back to the current DOCTYPE switcher mode if any part of the page did not validate. That’d stop ignorant developers simply slinging in the meta tag and carrying on producing tag-soup. It would force valid pages if you want to use CSS3 or the new ECMAScript. And all the while leaving the rest of the web totally unbroken.
In my eyes, the new switcher is brilliant, but doesn’t go far enough!