Validation |
The documents you write in HTML may look fine in your browser, but your HTML code might still have errors. Many browsers are designed to be fault-tolerant and to make good guesses when interpreting HTML code with minor syntax errors.
Why is it important to write legal HTML if the browser does not care? There are several reasons. First of all, different browsers may make different guesses about how to interpret invalid HTML. Broken code that displays satisfactorily in one browser may not work at all in another browser. You can be reasonably certain that conforming HTML will display properly in future browsers, but invalid code that seems to function today may fail in tomorrow's updated browser.
Writing clean HTML code protects you against technological change. Soon a wonderful new World-Wide Web authoring tool will come along, or a wonderful new scripting language will come along, and you will want to convert your World-Wide Web documents into a new format. If your documents exactly meet the HTML specifications, then it is likely that they can be converted automatically. However, if your documents have minor syntax errors, then you will have a lot of tedious work to do by hand in order to update them.
To validate your HTML documents, you may need to specify the
version of HTML
that you are using. You can do this by inserting above the
<html>
tag at the beginning of your document some code
to identify your HTML version, as in the following examples.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "https://www.w3.org/TR/html4/strict.dtd">
The preceding declaration is for conforming HTML 4.01 documents.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
If your document uses some of the older deprecated elements, you may need to use the preceding declaration.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "https://www.w3.org/TR/html4/frameset.dtd">
Documents with frames use the preceding declaration.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
The preceding declaration works with XHTML 1.0 documents.
There are various free services on the World-Wide Web that will check the syntax of HTML documents. Here is a list of some popular ones. You can find more extensive lists at FLFSoft and at Yahoo.
The W3C HTML Validation Service is provided by the World Wide Web Consortium, the official keeper of the international standards for HTML.
This service has user-friendly help pages.
Although it is a commercial site, Doctor HTML will check a small number of pages for free.
This program is a free utility for cleaning up HTML source code. It attempts to fix errors in HTML markup and will flag problem areas in your HTML files.
The NetMechanic can check syntax, verify links, and email you a report on its findings.
Bobby "analyzes web pages for their accessibility to people with disabilities."
Netscape's Web Site Garage "provides services for maintaining and improving your Web site."
Validation |