Creating Valid HTML Documents Means Cleaner Code and Easier MaintenanceI'll be the first one to let you in on a secret: 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. 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:
- Future compatibility
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 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.
- Current browser viewing
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 (IE supports the <iframe> tag, but Netscape does not) or not a part of the standard (the <marquee> tag is supported by IE and the <layer> tag is supported by Netscape, but neither are a part of the HTML 4 standard).
- Fewer strange problems
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.
For example, often people will design a beautiful page with tables and view it in IE. Then, a couple days later their friend calls them up to ask them why they have a blank page up on their site (as viewed in Netscape). The problem is that Netscape interprets the tables standard (the ending </table> tag is required) strictly and IE does not. You could argue that IE is being more flexible, but what if they decide in IE 6 to interpret the HTML standard more strictly? With the merging of XML and HTML into XHTML, this may easily become a reality. And suddenly, your pages no longer work for IE. But if you had written valid HTML, you wouldn't have had that problem.
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. Here are two of my favorite HTML Validators:
CSE HTML Validator
This is a powerful HTML validator that comes embedded in HomeSite, or you can get a standalone version. It checks your tag spelling, attributes, character entities, quotation marks, missing end tags, invalid nesting of tags, and more. If you are looking for a Windows based validator, this is a great one to use.
Doctor Watson
This is the online validator I use the most. Doctor Watson provides great analysis of Web pages that is easy to use and understand. It is also fast. One of the things I like best about it is the style checking. This isn't of CSS, but rather of how you wrote your Web page and includes warnings about things like using "click here" as a link, and other elements of bad Web style.
Related Articles
- Building great Intranet navigationWhile it may seem like a quick and easy task, defining the navigation structure and organization of your intranet site will be one of the most challenging tasks you will face in the course of your project. Doing it well, is also one of the most critical success factors...
- Why Validate Your HTML?Creating Valid HTML Documents Means Cleaner Code and Easier Maintenance. Ill be the first one to let you in on a secret: building Web pages isnt hard. With the software that is available now, you can write your Web page and have it up and viewable in half an hour...
- What does W3C Validation Stand For?This article will explain this to you if your website is W3C Validated and what W3C stands for and means.
- Get Listed In Google By Making An XML SiteMap And Without Spending A DimeIf you have been unsuccessfully trying to get listed in Google or just hitting roadblocks when trying to get more of your pages listed in Google, then you need to read this short article. I am about to reveal a simple SEO secret that can save you a lot of time, money and effort.
- PHP:Form Series: Validators & Client-side ValidationThis tutorial is really helpful to those of us who are a little intimidated by PHP:form. All of those hard to answer questions are easily explained in this simple to use educational web page. Hope you enjoy!
- Comprehensive Guide to XhtmlSince some time, the internet has been relying on HTML... or Hyper Text Markup Language... Since its been invented, many tries to replace it have been thought up, but none as successfull as XHTML (eXtensive Hyper Text Markup Language)... lets say that its HTML cleaned up...
- Cross Browser CompatibilityIf you want everybody to have access to your site, youd better make sure it is recognized by all existing browsers. These useful tips will help you check yourself.
- CSS Validation and HTMLHTML validation and CSS validation are controversial issues with some people. This article discusses some of the issues that have come increasingly to the fore in web development. The article will also provide a practical method that overworked webmasters can use to improve their website.
- How to Get Search Engines to Pay AttentionThis article tells you the most important ways to get search engines to index and rank your website highly. The author broke the article into 10 very good tips, and they will all help you reach your goals.
- HTML Forms Validation On The Client SideForm validation on the client-side is essential - it saves time and bandwidth; you also have better control to show the user the wrong field. This comparison of different validation methods includes comments for improving portability and maintainability.
