HyperText Markup Language/Validating HTML

From Wikibooks, open books for an open world
Jump to navigation Jump to search

There are fixed rules that define which tags may be used in an HTML document and where they can be placed. As your documents get larger, it can be difficult to ensure that everything is correct. There are automated tools that can check your HTML for you. These tools are known as validators. Several validators are free to use, including

Try uploading the index.html or index.htm file you created in the previous section to one of the validators listed above. Alternately, both validators will allow you to enter HTML directly, so you could cut and paste the example from this page into the validator.

There is also an HTML-validating Firefox extension that can validate HTML using either HTML Tidy or the SGML Parser (what the W3 validator is based on). It is available here for all platforms.

It is good practice to validate each HTML document you create. Note that many visual design tools will let you create invalid web pages, so it is important to check pages produced in these packages as well.

If the HTML document is valid, it means that the web page will display exactly as you designed it on stable, W3C-compliant browsers. In the case of text browsers such as Lynx, the text will format correctly so that it can be read easily by the user. Knowing HTML also means that you can edit the pages created using WYSIWYG programs manually, as these will often throw in unnecessary formatting which slows down the loading of your page.