|
HTML Tip:
New HTML Toolbox Repairs Your HTML
by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.
We've just released Version 2.0 of our HTML Toolbox service! This new version features an improved HTML validator that catches many code errors our older version of HTML Toolbox missed. Oh, and did we mention it can automatically repair most of these errors too?
While that's good news, be prepared to get a lower rating from the new code and a lot more error messages in your reports. Where our old HTML Check may have given your page a five star rating, the new code catches more problems, and may give your page only a three or four star rating as a result.
What sort of problems does the new HTML Check & Repair catch? The biggest difference is that we now check for HTML Content Model violations within your page.
The HTML Content Model is a set of rules that declare what HTML tags are allowed inside other HTML tags. If you've worked with HTML long enough, then you've probably seen browsers applying the Content Model, even if you didn't realize exactly what was happening.
For example, HTML usually allows a tag nested inside another tag to inherit the properties of the outer tag. If you place a paragraph tag inside a FONT tag, the paragraph will inherit the FONT properties.
However, there are some cases where tag nesting doesn't produce the effect you want. Perhaps the most common example of this is nesting an HTML TABLE inside a FONT tag. If you try to wrap a FONT tag around a TABLE, most browsers won't apply the FONT to the TABLE's contents.
For example, look at this code:
<FONT COLOR="red">
<TABLE BORDER="1" align="center">
<TR>
<TD>Is this text red?</TD>
</TR>
</TABLE>
</FONT>
|
Notice that the text inside the TABLE below isn't rendered in red. That's because the Content Model doesn't allow a TABLE tag to be inside the FONT element. If you've ever seen cases like this where tag nesting didn't get you the effect you wanted, you've been bitten by the Content Model.
Note that in some cases both Netscape Navigator and Microsoft Internet Explorer will forgive Content Model violations, even though they're not valid HTML. However, as HTML is replaced by XHTML and XML, adherence to the Content Model will become much stricter.
While our old HTML Check wouldn't catch Content Model violations like the one shown above, the new HTML Check & Repair will report these errors:
0001: <FONT COLOR="red">
^Error: missing </font> end tag before <table> tag
^Hint: <table> element NOT allowed in <font>...</font> element
^Repair: closing open <font> element with </font> end tag
^Repair: trimming empty <font> element
0002: <TABLE>
0003: <TR>
0004: <TD>Is this text red?</TD>
0005: </TR>
0006: </TABLE>
0007: </FONT>
|
That's a lot more output, but it gives a good idea of what sort of error we found, and how we'd fix it. The red text describes the error. In this case, we expected to find a closing FONT tag before reaching the TABLE tag on line 1.
Blue text elaborates on the problems we found, explaining why this error may have happened. In our example, the blue text explains that the TABLE isn't allowed inside the FONT element.
The green text is perhaps the most interesting part of the new report because it describes how HTML Toolbox would go about repairing this page. HTML Toolbox features a powerful engine that can actually correct errors in your HTML. With the click of a button, HTML Toolbox will correct most of the errors it found on your page.
In our example, HTML Toolbox reports that it would close the FONT tag before the TABLE tag. Then, since HTML doesn't allow empty tags, it would trim the empty FONT tag from the page.
Note that HTML Toolbox works on a copy of your Web page; it doesn't directly change anything on your site. You can review the repaired copy of your page and compare it to your original page. If you like what you see, you then publish the repaired page to your Web site.
This new repair feature is available only to HTML Toolbox subscribers. The new service is available at a special introductory price of $60 a year for sites with up to 100 pages. The service costs $200 a year for sites with more than 100 pages. Click here to sign up.
Even if you aren't a subscriber, you can use the new features of HTML Toolbox to find errors in your site. Click here to run a free sample test.
|