Do what you like to my CSS, but stay out of my HTML
Note: This article was written for a previous version of the site and is likely out-of-date.
This week Microsoft revealed that to trigger standards rendering in IE8, web authors will need to use a new meta tag to specify which version of the IE rendering engine to use. Alternatively (and this wasn't immediately apparant) authors can just use an unknown doctype such as the HTML5 one which would automatically trigger standards mode. I'll say it outright that I'm not a fan of the idea but I can see why it's been done, I find it arrogant of Microsoft to demand special treatment when we've already had to put up with quite a lot of IE's rubbish over the years. This is coming from someone who is normally an apologist for Microsoft, normally I take the viewpoint that whilst making things work in IE is a pain it's usually relatively straightforward once you reach a certain level of experience and become aware of the problem areas.
But there is something that is bothering me alongside this, why the hell do we keep making changes to our structural/context layer (HTML) in order to control how the presentation layer (CSS) behaves? Why should my use of a valid doctype mean that my CSS magically works properly? A doctype is used to validate the structure of an xml document, it has nothing to do with how it's displayed, and why are we still using doctypes anyway? XML Schema Definitions are much easier to develop, from what I gather they give you a lot more flexibility and they're really easy to understand. This isn't a rant about doctypes though, this is a rant about me having to change one area of my code to affect how a completely different part of my code performs.
So we have to use proper doctypes to get IE6 and IE7 to use CSS more correctly than IE5, but that's not enough - we also have to add conditional comments into our HTML so that we can deliver special CSS to them to clean up the things that IE still can't do right. Now we have IE8 to look forward to, but now we have to add even more to the head of our documents to trigger the probably-still-not-right-but-getting-closer rendering mode in this new version.
Why the hell aren't we shoving all this information in our CSS instead? If this information is controlling how the CSS works surely it would make sense to configure it there? In a proper deployment environment it's a piece of cake to update CSS because it's generally served from a different web server to the web application, we can easily tweak the CSS for new browsers without so much as having to reload/redeploy anything. Quite frankly, whilst I prefer clean CSS due to being a bit of a perfectionist, if I have to stick all this nonsense somewhere it'd rather it be in the CSS than the HTML. I consider it much more important to have valid and streamlined HTML than CSS.
Just a thought.
Originally published on .