Pained by Invalid Code

Aug 12, 2008

I run an HTML/CSS validator in my browser for development reasons but I leave it on when I cruise the inter-tubes. When a site validates it shows a little green check box, making me very happy. When it doesn’t validate, a glaring red X appears in the corner – prompting me to question why. It’s a distraction from my main purpose of just interacting with a site. (Though it’s my fault that I leave it on all the time). But it only pulls me away from the site just out of curiosity of why it would be invalid. There is a reason or two that I could live with. But there are many other reasons that I cannot.

I’ve mentioned before that I am a stickler for HTML/CSS validation when I build web pages to the point that I’d be called militant in every respect. It pains me to see beautiful sites with that large red invalid X floating at the bottom of my screen – I’m an advocate of standards and accessibility and not a legalist.

Why the invalid code?

Unfortunately, even though I might just be at a site to read an article, that little warning will cause me to examine their code. Why do such beautiful and well constructed sites let their code go invalid? I guess there are a few reasons:

  1. They don’t care – ie Google – for such a simple page, it’s amazing that they wouldn’t even enclose their tag attributes in quotes – but hey what do they care if their site isn’t valid? I haven’t stopped using it.
  2. Widgets/3rd Party Code – if you’ve ever wanted to pull in JavaScript widgets – more often than not they a riddled with bad code. But this probably falls into the other 2 points – it’s just the developer that’s lazy or doesn’t care, not the site owner. I’ve always wanted to use “Disqus”: to run my comments, but their code is invalid here.
  3. Laziness – sometimes your just ready to launch a site – I mean hey it looks good, get it out there and worry about the bad code later, if you’ve looked at the validation at all.
  4. Lack of Knowledge – There seems to be a good bit of misunderstanding on why sites should be valid in the first place – if a site works, isn’t that enough?
  5. Content Management Systems – They’re usually built to help accommodate users – but more often than not, user’s end up messing up the original intended vision. Who knew they’d like pink text?

So really, why with all the hard work would you simply let this go when there are so many reason for having valid code?

Why validate in the first place if the site looks like it should?

Because I might happen onto your site and call you out, that’s why. Why? Because that glaring red X in the corner of my screen kills your reputation. I won’t read anything you have to say.

Really though just kidding – I won’t call you out becuase that’s rude and a waste of time and I’ll still listen to what you have to say. If I didn’t have my validator running in my browser all the time I would have never noticed. That reminds me of a good quote from Jeff Croft:

Usually, if you’re validating someone else’s code, it’s because you’re being an asshole.

I’m not going in to point out issues with their site, I’m really just looking to see if they’ve run into the same issues that I have…

So what are some real reasons for validating? Here’s a good article straight from the W3C – Why Validate?– right to the point. Here’s what I have to add:

Agnostic browsing

Developing code to standards will ensure that even browsers that don’t exist yet will know how to handle your site. There might be a new amazing browser that comes out that will throw errors if the code is wrong (although that probably won’t happen anytime soon). It’s tough to test a design in every browser that exists at the moment but at least we know that it’s the best it can be with valid code and has more of a change across all platforms.

The bulk of browsers

If everything was valid browsers could stop having to figure out ‘what you really meant’ and instead concentrate on implementing new standards. Why has IE resorted to building such a huge program to handle the mess of tag soup that’s out there? It’s because of the above reasons I just mentioned – Laziness and lack of knowledge.

A step toward accessibility

I can’t stress the importance of accessibility enough – yet people will say – “Oh, blind people aren’t in our market” or “our products are geared toward able bodied people” without really understanding the importance. And that really really sucks! If one day I find that I have mobility issues or visual impairment and have to live with the current state of sites, I’d be truly unnerved.

People just don’t realize that there might be a blind person browsing their site and from what I see in forums – almost every topic about accessibility has a handful of people that say ‘why bother’. Why Bother!!!? Oh, how about a lawsuit against you for discrimination! I could go on but I won’t – I’m really adamant about this subject too.

Anyway, although validation doesn’t ensure accessibility it is one of the pieces. If you’re serious about accessibility you should be serious about your underlying code.

How do I create valid code?

That’s an easy one. Most coding environments have a built in validator that will show errors – don’t don’t ignore them. Mainly I rely on my Firefox plug-in – HTML Validator – set to ‘serialize’ – to run a SGML parser and then HTML Tidy. There’s also the W3C’s online validator where you can upload code or point them to your site.

Did I drag on enough? I think so. Please Please Please create sites that are valid. Think of the children.

Share the Love: | digg | magnolia


Share Your Comment

You must preview your post and then hit submit.

If you haven't looked already check out my articles, my tutorials or my portfolio. If you need something else, please feel free to chat with me.

All content of this website (unless marked otherwise) is © copyright bradley j. cooper 2006-2008

Brad's AvatarI'm Brad Cooper a web designer/front-end programmer with a passion for actualizing visions. I try to create a piece of art in each site that I put together both visually and technically. I currently work outside Philadelphia and live in Marlton, New Jersey.

You can find me online:

Twitter | FriendFeed | Flickr | Delicious

Or keep up to date and:

Feed Icon Grab My Feed.

If you have a question or need some help, feel free to Chat with Me.

Recent Articles

» New Window Script Redux

» Magnolia - How social bookmarking should be - social!

» My Affinity for Color 2

» Pained by Invalid Code

Recent Tutorials

» Unobtrusive Expand and Collapse Navigation

» Forcing New Windows on Users Script

» Shorten document.getElementById

» Google Feed API Tutorial