By Jennifer Kyrnin
HTML is based upon rules to create it and browsers use those rules to display
the Web pages consistently. However, because HTML is written by people, there
is a lot of possibility for error.
Programmers know that when they write C code they have programs like debuggers
to find problems, and they also have a program called "lint" to check for errors
in the code. The same is true for HTML writers.
Once you have written a Web page, you may notice that things you don't expect
are happening. Unless you've written the page in a WYSIWYG editor, invalid
HTML may be causing the problem. If you validate your HTML, you can correct
those problems and get a page that works as it should.
About.com Validated
One of my favorite online validators is Dr.
Watson. It has a lot of different options and gives you more than just
information about the HTML - you can find out how fast your page loads, verify
links (including images), check search engine compatibility, and many other
things.
I put the About.com front page,
http://www.about.com/, through the Dr. Watson validator. I chose to validate
it with no special features, just "Analyze HTML syntax". These are some of the
results.
Dr. Watson indicates the line number of the HTML so that you can easily find the
problem. For example, the first error found is:
line #10: : use of ' for attribute value delimiter is not supported by
all browsers (attribute CONTENT of tag META)
And line #10 reads:
<META http-equiv="PICS-Label" content='(PICS-1.1"http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" on "1998.04.15T07:38-0800" r (n 0 s 0 v 0 l 0))'>
What Dr. Watson means here is that most attributes should be
quoted with double quotes. Some browsers will get confused by the use of
single quotes.
Explanation of some other potentially confusing results:
line #15: : attribute 'TOPMARGIN' for <BODY> is extended markup (choose the appropriate extension option to allow this).
Extended markup is HTML that is beyond standard HTML. In
this case, the topmargin attribute is an Internet Explorer attribute only. It
does nothing in Netscape and other browsers.
line #15: : unknown attribute "MARGINWIDTH" for element <BODY>
The marginwidth attribute is not a recognized HTML attribute
line #164: : </TR> on line 161 seems to overlap <TD>, opened on line 164
This is a tricky comment. Because of the number of nested
tables on this Web page, Dr. Watson may be getting confused. When I see this
type of report, I ignore it until I've fixed the other errors I find. Then,
if I still find errors, I'll validate the page in another validator.
line #216: : unknown attribute "HEIGHT" for element <input>
This is a common error. The input tag does not yet
recognize the height, width, and alt tags that would be used when using
an image as an input button. However, it's still a good idea to put them
in, as these attributes work in the same fashion they do for the <img> tag.
line #229: : value for attribute WIDTH (100%) of element TABLE should be quoted
(i.e. WIDTH="100%")
Many people leave off the quotes from attributes. In fact, many HTML editors
write the HTML without quoted attributes. This is usually not a problem, but
can cause confusion. When in doubt, it's best to use quotes on all attributes.
line #333: : unknown attribute "FONT" for element <font>
This is an actual error in the HTML code. It appears that there were originally
two font tags that were incorrectly concatenated together
<font face="ms sans serif, geneva, helvetica" font size=-2>
line #587: : </A> on line 587 seems to overlap <B>, opened on line 587
When you write HTML, you need to make sure that tags are nested. For example, if
you start a series of HTML tags: <b><i> close the inner tag first,
then the outer tag: </i></b>.
These are not all the errors
The About.com home page has a lot of HTML errors. This is mostly because it is a
very complex page. It is built using a database and has a lot of nested tables. It
also is fairly reliable in how it displays, but correcting the HTML errors would
insure that the page stays consistent as browsers change.
The final page in this series includes the full results of the Dr. Watson
validation.
Next Page >
The Full Results
> Page 1,
2
Previous Features