1. Technology

Why Validate Your HTML

Creating Valid HTML Documents Means Cleaner Code and Easier Maintenance

By

Learning to validate your HTML is an important step for most designers. By writing valid HTML you ensure that your pages are standards compliant and will run on the most user agents and web browsers.

Building web pages isn't hard. With the software that is available now, you can write your web page and have it up and viewable in half an hour or less. And with these tools, why would you need to run an HTML validator on your HTML to find errors? Well, you don't have to, but if you want your pages to stay viewable through future versions of HTML, or you want newer browsers to be able to display it correctly, then writing valid HTML is the place to start.

There are several specific reasons for writing valid HTML, and using an HTML validator to insure that what you write is valid:

  • Compatibility with future versions of HTML and web browsers
    As browsers evolve, they come closer and closer to supporting the standard HTML as written by the W3C. Even if they don't fully support the most recent version of HTML, the browser builders go in and make sure that they are compliant with older versions of the standard. If you are writing non-standard HTML, there is a chance that as browsers evolve, they will no longer support your web pages. A good example of this is a trick that some web developers used with an older version of Netscape. If you included multiple body tags with different colors, Netscape would load them all in succession creating a fade-in or flicker effect as the page loaded. This trick no longer works, as it relied on an incompatibility of the browser.
  • Accessible to Your Current Audience
    Unless you know for a fact that your entire audience is using a specific browser, you are setting your site up to annoy some of your readers if you make it inaccessible to them through invalid or non-standard HTML. Many HTML validators will check your HTML for browser specific entities and alert you to their use. Browser specific HTML can be part of the standard or not a part of the standard. Don't assume that just because only one browser supports something it's non-standard. Or if multiple browsers support it, that it is part of a standard. For instance, HTML5 is supported by Safari, Opera, Chrome, and Firefox, but it is not yet a recognized standard.
  • Reduce Unexplained Errors
    I am often asked to look at web pages for people to tell them why the code is doing something strange. I can usually come back in just a few minutes and tell them what is wrong. Why? It's not because I know HTML inside and out, it's because I run their page through an HTML validator. This usually points out a problem with the HTML, that, when fixed, solves their problem as well.

HTML Validators

There are a lot of validators available. You can get ones that are run on your computer, embedded into your HTML editor, or online on your live web pages. I list my favorite HTML validators in this article: Best HTML Validators.

Current HTML and Web Design Articles

©2014 About.com. All rights reserved.