Why should I validate my HTML pages?

One of the important maxims of computer programming is: Be conservative in what you produce; be liberal in what you accept.

Browsers follow the second half of this maxim by accepting Web pages and trying to display them even if they're not legal HTML. Usually this means that the browser will try to make educated guesses about what you probably meant. The problem is that different browsers (or even different versions of the same browser) will make different guesses about the same illegal construct; worse, if your HTML is really pathological, the browser could get hopelessly confused and produce a mangled mess, or even crash.

That's why you want to follow the first half of the maxim by making sure your pages are legal HTML. The best way to do that is by running your documents through one or more HTML validators.

What other validators are there?

FIXME

How does The Validator work?

The Validator is based on James Clark's nsgmls SGML parser. The Validator itself is a CGI script that fetches your URL, passes it through nsgmls, and post-processes the resulting error list for easier reading.

How do I set The Validator to validate in HTML2/HTML3/Netscape mode?

Unlike WebTechs, The Validator does not allow you to select a document type on the fly. If your document is not intended to be HTML 2.0-compliant, you must add a corresponding DOCTYPE declaration to your document; see the section on DOCTYPE for more information. If your document does not have a DOCTYPE declaration, The Validator will assume an HTML 4.0 document type (and will tell you it is doing so).

Help! The Validator spewed a zillion error messages on my page!

Don't panic. Did The Validator complain about your DOCTYPE declaration (or lack thereof)? Make sure your document has a syntactically correct DOCTYPE declaration, as described in the section on DOCTYPE, and make sure it correctly identifies the type of HTML you're using. Then run it through The Validator again; if you're lucky, you should get a lot fewer errors.

If this doesn't help, then you may be experiencing a cascade failure — one error that gets The Validator so confused that it can't make sense of the rest of your page. Try correcting the first few errors and running your page through The Validator again.