Valid code – to whom does it matter?

I read a post in a mailing list today that made me think. I know that the homepages for the big search engines are full of errors. They don’t validate – and it doesn’t matter. They’re not hurting for it. It makes not one iota of difference as far as search engines go whether code validates.

I try (I don’t always succeed, but I always try) to make sure my code is valid for both HTML and CSS. Why do I do this? Because I feel it’s the right thing to do.

I know that there are usually many ways to accomplish the same result when you’re building a web site. I get that, and I like that. But I with my idealist viewpoint believe that there are ways that are more clean, less intrusive, easier to later understand and change than others.

Take for instance CSS hacks. When I first began using CSS heavily, I used hacks. But since I discovered conditional comments, I very rarely use a hack (the last one was about four months ago and specific to Opera). I like conditional comments because they seem to me to be a cleaner, more correct solution than toying with presentational elements in CSS that may later reveal incompatibilities as new browser versions are released (look at the list of CSS hacks that stopped working in IE7).

I met a designer last week whose work I love – he’s a very talented individual and a standards advocate as I am. We were talking about a common issue in CSS and I asked how he got around that – he agreed that conditional comments were the way to go but that he defined them within the stylesheet and not in the actual HTML page. He whipped out his laptop and showed me what he meant.

I looked at the code and thought ‘that’s a hack’ even as he said ‘this is a conditional comment.’ He supposed that a purist wouldn’t agree with his labeling.

I’m a purist. I think hacks are messy, they’re more like bandaids than real solutions. For me, conditional comments are the cleaner fix.

I validate because I care very much that my code is clean. I define clean, in part, as being error-free, and validating helps me accomplish that, most of the time. I know it doesn’t matter to search engines, nor to the vast majority of my clients. But I consider my work as a web designer/developer to be a craft – and it matters to me.

6 comments

  1. I had a similar conversation with a friend of mine recently. I use a content management system and as a result have no control over code. He uses pure code and takes great pains to be sure his code is clean and valid.

    I can’t understand why ‘clean’ code is important aside from personal standards, as search engines and users aren’t concerned.

    But I do admire that people are going to the trouble to work to these high standards.

  2. I agree with Mark H. and offer that valid code is more likely to be shorter, will load faster, will be accessible and therefore seen more widely. Ignore validity at your peril.

  3. Maintainability – clean code makes it much easier to find bugs and make changes/improvements.

    Cross-browser consistency – how on earth can you have a hope of fixing CSS rendering bugs if you don’t start from a standard valid position.

    SEO – ok it’s arguable since Google say they can extract the content despite poor code, but why make it harder for them? And from personal experience every site I’ve either built or rebuilt as valid code has done well, while many of those where I wasn’t allowed to rebuild have done less well.

    Our dad’s generation called it craftsmanship.

Leave a Reply

Your email address will not be published. Required fields are marked *