Validation: What is it and why should I care?

Validation is the process of running your HTML and other XML documents through the W3C validator to check for conformity against the specification. But is it important?

Language

You're talking with a friend who's new to the country. Their English is pretty good, though broken in places. You understand everything, until they get to one word which they don't know the translation for, and you struggle to figure it out given the context.

Computers are the same – HTML has its own rules and syntax. If you code something that doesn't quite adhere to the specification, your web browser will have a jolly good go at assuming how you meant to code it, and fill in the gaps. Browsers, like humans, are very good at this sort of internal error correction.

But it doesn't always work. When it doesn't work, you'll obviously notice the error right away and set about fixing it. But sometimes it does work, for a while. In the age of weekly and daily browser updates we must treat each update like a different person. Interpretation of the same language is near identical, but understanding of certain words may not be the same. This is a problem for a web browser, because it means that something coded improperly may work one day, then not the next.

Natural selection

Internet Explorer 6 was a hugely buggy browser that itself did not render pages as is was supposed to. Naturally, most developers at the time were coding pages specifically to work in this browser, even though their syntax was higgledy piggledy. Some developers, like me, were coding in Firefox first; a browser which was relatively new to the scene but followed the HTML specification much more closely. There were many bug fixes applied to code to make it work properly in IE6 afterwards, and this was the first era when resentment towards Internet Explorer really began to set in.

Internet Explorer 7 is released, and as you may expect, several of the bugs from IE6 were resolved. The browser followed the HTML specification slightly more closely. And half of the web pages on the internet broke. The moral of the story? If only people had bothered to write code properly in the first place, they wouldn't have suddenly inherited a lot of warranty work.

First isn't always best

In the current era of development, many developers are quick to rush to the experimental elements which aren't yet part of a ratified spec. Using draft elements in your clients HTML is dangerous; we've already seen multiple draft elements from the HTML5 spec deprecated. And since those elements weren't in a previous version of HTML, they have been removed completely. This, along with the already apparent non-validating code issue, should be a serious concern for both you and your clients.

Validating your code will ensure that your website looks as good next year as it does today. Not only this, but valid HTML is a well formed XML document, which makes crawling your site much easier. The Googlebot, and other bots, will thank you for this. Improving your crawling and therefore your SEO is the tip of the iceberg; a valid document is also a much more accessible page. Win, win, win!

The only question left to ask is, why aren't you validating your HTML?

W3C Markup Validation Service