Next section: HTML and SGML
Up to main index

[see parent document for copyright information]


Section 1: KGV and other validators

What does KGV do?
The Kinder, Gentler Validator (hereinafter "KGV") is sort of like lint for C. It compares your HTML document to the defined syntax of HTML and reports any discrepancies.
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?
Besides KGV, the three most commonly mentioned HTML validators are:
     Weblint: http://www.cre.canon.co.uk/~neilb/weblint/
    HTMLChek: http://uts.cc.utexas.edu/~churchh/htmlchek.html
    WebTechs: http://www.webtechs.com/html-val-svc/
        (née HALSoft)

Weblint and HTMLChek are heuristic validators --- that is, they do not completely parse your HTML markup, but simply scan it looking for errors. The advantage of this is that they can detect constructs that are legal HTML but considered "bad style", such as an <IMG> tag without an ALT attribute; the disadvantage is that they can fail to detect some errors. WebTechs is similar to KGV; both operate directly from the HTML language definition, and both strictly obey the rules of SGML. If your document passes one of these validators, you know it's clean.

I recommend using a combination of validators: one of Weblint or HTMLChek, and one of WebTechs or KGV. Each has features that the others don't, and they complement each other nicely.

How does KGV work?
KGV 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.
What do the options on the KGV main page do?
In addition to running your document through nsgmls, KGV can perform other checks and transformations on your document:
How do I set KGV to validate in HTML2/HTML3/Netscape mode?
Unlike WebTechs, KGV 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, KGV will assume an HTML 2.0 document type (and will tell you it is doing so).
Can I install a copy of KGV locally?
Apparently, you now can; see http://validator.w3.org/source/.
Help! KGV spewed a zillion error messages on my page!
Don't panic. Did KGV complain about your DOCTYPE declaration (or lack thereof)? Make sure your document has a syntactically correct DOCTYPE declaration, as described in section 2, and make sure it correctly identifies the type of HTML you're using. Then run it through KGV 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 KGV 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 KGV again.

I used the Netscape document type, but KGV still doesn't like my tables.
Unfortunately, this is one of the areas of HTML that Netscape botched pretty badly; some of Mozilla's behavior regarding tables simply cannot be represented in a DTD. The two thorny bits are:
I love your validator/I have a question about your validator.
Well, thanks, but it's not my validator. KGV is maintained by Gerald Oskoboiny (gerald@cs.ualberta.ca); questions or problems concerning the validation service itself should go to Gerald. This FAQ is maintained separately by me, Scott Bigham (dsb@killerbunnies.org); questions like, "This error isn't listed; what does it mean?" and "Are you sure this is illegal HTML?" should go to me.

Next section: HTML and SGML
Up to main index

[see parent document for copyright information]

Sending feedback? Check here first.

HTML 2.0 Checked!

Last update 08 Aug 98

dsb@killerbunnies.org