Why Is It Important To Validate Web Pages?
Posted in Design
For years now web development has been based on browser tolerance. We're all guilty of pushing browsers to their limits to test how much abuse they can take. The abuse I'm talking about is bad code.
People would throw a lump of HTML at a browser and expect it to make the best out of it. This mindset led to questionable coding practices such as complex browser sniffing scripts, serving different markup and stylesheets to each browsers, tables for layouts, font tags, spacer gifs, etc.
On the receiving end, browser manufacturers had to accommodate bad code and have their browsers deal with it. As a result, the behavior of each browser was different. "Stupid browsers!" Or are they?
Try this exercise. Go to the W3C Markup Validation Service and type in www.yahoo.com. This morning the validator identified 204 markup errors! A lot of them are similar but still... In all those 204 cases a browser has to act on some assumption how to handle the code. So what do you expect from a browser after all?
Take a look at the home page of our mothership, www.microsoft.com, as it renders in the Opera 7.50. It looks the same way in Firefox. The rationale is simple: someone simply assumed their code would work outside of the Internet Explorer realm. I can understand little differences in padding and margins, but not the fact that all product logos are missing! In this case these two browsers refused to take abuse.
One more example. Does your car engine make a terrible squealing sound? It's probably begging you to change its timing belt. No biggie, you say? Improper timing can lead to engine overheating. Spark plugs fire the fuel/air mix late, i.e. after the piston moves down from the top of its stroke. If spark plugs fire too late for the mixture to burn the cooling system has to deal with more heat than necessary. Also, due to mistimed ignition you're wasting more gas, forking over more money at the pump and not getting due performance from the engine. You might not hear engine knocking because your ECU retarded ignition but the problem is still there. The point is you can drive the car but the consequences can be expensive.
Web projects are the exact same way. You can pretend they work but inside they are "knocking".
By now you should've realized you need to keep your code as clean as possible. Go to the Markup Validation Service, paste your URL and inspect the error report (if any).
Same goes for your stylesheets. Go to the CSS Validation Service and run a check on your CSS. Sometimes you have to resort to using CSS hacks. Most likely the validator will not like them. Don't worry, as long as you understand why you need this hack and keep other errors to the minimum you're fine. See if you can rework your stylesheet without hacks.
Validators are not seers and revelators. They are only a piece of code without mind and heart. As such, they don't look into the structure of your code or its logic. They only check it against a spec. It's completely up to you to make sure your code is sound. Even if validators don't catch any errors keep your mind open.
What About Validation For Accessibility?
I should also mention Bobby, an online validator of compliance with accessibility guidelines, such as Section 508 and Web Content Accessibility Guidelines 1.0. These aren't standards per se, but more of guidelines. I encourage you to also check your design against them, too, but the results are even more subjective that those of the previously mentioned validators. By making your code as closely compliant with accessibility guidelines you will ensure those who are visually impaired or have motor disabilities can use your site too. Still not convinced? Think about Google, world's largest blind user. It doesn't pay attention to JavaScript, images, sound, Flash and the like. It does pay attention to your alt and title tags.
The State Of Web Standards In ASP.NET
I want to write a whole post about it, so I'll only summarize here. It might be challenging to make your ASP.NET code fully compliant with web standards. Often times you can simply blame server controls and adaptive rendering itself. But... that doesn't excuse us. Try it. Just try it. Eventually it'll become a norm.
