Why should web pages be validated? Validation assures that your HTML or XHTML code is compliant with industry standards. This in turn means that your web pages should render (display) without errors in a browser. It also helps assure that the code can be easily read by search engine spiders, which is essential if you want the search engines to index and rank your site.
What validation does not do is assure that the code is written efficiently. There are still numerous ways that code can be inefficiently constructed, yet still comply with industry standards. Nonetheless, if there are errors in web page code, browsers may repeatedly re-render the page, which slows the overall rendering process. Search engine spiders are much less forgiving than a browser. If a spider algorithm does not understand the code, it will abandon the indexing of a site. A validator identifies numerous common coding errors, such as improper tag nesting and invalid attributes. It is therefore very worthwhile to validate the code and make the recommended corrections to assure compliance.
Online validation tools
The W3C (World Wide Web Consortium) is the international organization that maintains the coding standards for HTML, XHTML, CSS and other Web scripting languages. They have an on-line HTML/XHTML validator that is considered to be the gold standard for testing. The validator is found here:
Use of the validator requires the addition of a proper Document Type Declaration (DTD or Doctype) at the top of each web page. A Doctype declaration tells the validator which version of HTML or XHTML you are using and establishes the standard for validation. The validator will not work without a Doctype declaration.
Many Web site designers and developers skip the use of the Doctype, but it should used on every page. The Doctype also tells a browser which version of HTML or XHTML you are using and helps assure proper rendering of the pages based upon the standard you select. Without a Doctype, Web pages can sometimes display differently than intended. Most modern browsers contain multiple rendering engines that can display a web page differently if a standard is not declared. The W3C maintains Doctype declaration standards, which can be found at the following location:
The most common HTML DTD is HTML 4.01 Transitional. The most common XHTML DTD is XHTML 1.0 Transitional. With static HTML or XHTML pages, the DTD must be the first line of code in your script. The DTD is client-side code, so if you use ASP, PHP or other dynamic languages, the DTD needs to be the first line of code sent to the browser and not necessarily the first line of code in your script. If you do not understand the last sentence, then you are using static HTML pages and the DTD must be the first line of code.
There are two ways to use the validation service. First, you can go to the W3C Markup Validation Service page listed above and enter a URL for the page you wish to validate. The alternative is to include a snippet of HTML code on a web page that activates the validator and submits a page automatically. Once a page is successfully validated, the following code (or an HTML version) is offered by the W3C validator.
<a href="http://validator.w3.org/check/referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a>
The code can be included on a web page and will display a clickable icon that submits the page automatically.