California Educational Data Processing Association
The DataBus - Vol. 38, No. 1
December, 1997-January, 1998
How Correct Is Your HTML Syntax?

Addison Ching, California State University Office of the Chancellor

Web browsers are fortunately very forgiving, for the most part. They faithfully display web page after web page, representing colors, font changes, tables, and other textual embellishments as accurately as one can imagine. No one would suspect that under the cover, where the true HTML source can be inspected using a "view HTML source" pull-down window or some equivalent operation, that errors might actually exist. One might even argue, "But the pages display properly!"

If you started developing web pages when the Internet was in its infancy (as far as K-12 use is concerned), you are probably "self-taught," relying on one or more tutorials and references that were available on the web. You probably did some reading, developed an experimental page or two, displayed it with the NCSA Mosaic browser, and were satisfied at the results of your efforts. If the page didn't quite work out the way you anticipated, you probably fiddled with it a bit, dug back into the tutorials to see why your instructions produced that mess of a page it did, then made the appropriate changes that gave you the look you wanted. From this discipline you probably developed some very bad and syntactically incorrect habits for writing HTML--which still exist in the pages you're currently developing. But the pages display properly!

If you recently picked up HTML as a hobby or as a responsibility of your job, you're probably using one of the many now-available web page development tools. These might include Adobe PageMill, Microsoft's Front Page, or maybe even a shareware tool such as Arachnophilia or Allaire's HomeSite, an excellent and very highly rated web development tool.

Or you might be using Microsoft Office 97's built-in HTML conversion utilities for Word, Excel, and PowerPoint. Other popular programs such as Adobe PageMaker also have HTML exporting routines that will convert your formatted text into HTML, sometimes with results you didn't quite expect!

Whatever method you're using to create HTML, are you assured that your HTML syntax is correct and conforms to HTML standards? What do you base that assurance on? Do you assume that if your page displays properly on the most popular web browsers in use that your syntax is correct?

Guess again! Many people that write "raw" HTML--that is, coding HTML statements from "scratch" using a text-based word processor--inadvertently include syntax errors in their coding. This may be due to bad coding habits or carelessness. How many of you former programmers can remember coding that COBOL program with perfect syntax--no compilation errors and it executed correctly the first time? HTML coding is no different--after all, it is too a programming language.

Commercially available development packages are no different; just because the program "generates" the required HTML doesn't necessarily mean that it generates the HTML statements with correct syntax. The programmer that wrote the HTML generator probably used the same guidelines that you've used in the past--if the web browser displays it properly, it must be correct! The HTML conversion utility for Microsoft's PowerPoint97 generates HTML with a handful of errors--a misspelling, extra spaces where they shouldn't be, and the absence of quote marks where they should be. But the pages display properly!

So why the fuss about syntactically correct HTML?

First, the fact that the incorrect HTML displays properly could be due to a "bug" (or is it a feature?) in the browser that could be corrected or modified in a subsequent release. This means that incorrect syntax that displays properly today may not at some point in the future.

Second, incorrect HTML, while displaying properly in Netscape Navigator or Microsoft Internet Explorer, may not display properly on other, lesser-known browsers (Mosaic, Lynx, or shareware) that might be in use.

Third, incorrect HTML produces inconsistent results on the browsers that compensate for the errors. The only way you can guarantee consistent format and layout is to ensure that your HTML is correct. Fortunately, there is a very good tool that is available to accomplish this.

CSE 3310 HTML Validator by AI Internet is an effective tool that will not only evaluate your HTML syntax and point out errors, but it will also help you to develop correct HTML syntax habits. The tool will work in stand-alone mode but can also be incorporated within Allaire's HomeSite HTML development tool as a complete HTML development package. It features a complete diagnostic set with options that allow you to specify how certain characters (such as ampersands and high-ASCII characters) should be handled. The current release version 2.50 includes support for HTML 4.0 as well as for unique features of Netscape Navigator 4.0 and Microsoft Internet Explorer 4.0.

When used in conjunction with Allaire's HomeSite HTML development program, a single function key is used to invoke the validator. Word wrapping is automatically turned off and HTML statements are assigned temporary statement reference numbers and appear in their own window. Any errors detected by the validator are detailed in a separate frame window that references the statement number and describes the error. The user can click on the error flag and HomeSite will locate and highlight the offending statement. At this point, editing can be done to correct the error.

The validator is quite thorough, detecting extra spaces where they don't belong, flagging incorrect use of HTML instruction options, and catching nesting errors where closing tags appear out of sequence or not at all. It is very refreshing to run your HTML through the validator and end up with a "No errors found" message. However, if the validator detects any syntax errors, its concise diagnostics will allow you to locate and fix your errors quickly.

Additional information about HTML validator and an evaluation copy of the program can be obtained at http://www.htmlvalidator.com. Information and an evaluation copy of Allaire's HomeSite can be obtained at http://www.allaire.com.

Return to Index Return to December-January index