HTML validation

Posted by David Haley on Thu 28 Sep 2006 05:47 AM — 6 posts, 20,876 views.

USA #0
Hi Nick; I installed an HTML validator extension for Firefox and it's complaining an awful lot about the forum output. Seems that it's unhappy about <li/> tags; it wants them to be simply <li>. Here are some example warning messages:

line 417 column 6 - Warning: missing <li>

line 417 column 1 - Warning: trimming empty <li>


Basically these happen for every list item on the page.
Australia Forum Administrator #1
I submitted a sample page with such things in it, namely:

http://www.gammon.com.au/forum/?id=6581

to the W3C validator and it passed the validation:

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.gammon.com.au%2Fforum%2F%3Fid%3D6581

It said:

This Page Is Valid HTML 4.01 Transitional!

Australia Forum Administrator #2
The reason I used <li/> is that, strictly speaking in XML, if there is no closing </li> then the opening <li> should be <li/>.

However I understand HTML is not strict XML.
USA #3
Hmm. Looks like something is wrong with the validator plug-in, since indeed, the W3C validator seems happy and they set the standard after all.

About <li/>, though, in XML is that really valid? You're putting content in the <li> element therefore the CDATA has to be between open and close tags. Interestingly, though, if I remember correctly, the validators complain about closing the <li> tag...
Australia Forum Administrator #4
Well, the validator accepted it, so is that, by definition, valid?

However I take your point. If you see this page:

http://www.w3.org/TR/html401/struct/lists.html

They seem to be suggesting that <li> is correct (without the </li> too). In XML that simply would not be correct.
USA #5
Oh, I think I know what might be going on. My validator is giving warnings, not errors, whereas the W3C validator seems to only care about errors. At least, I can't see to turn on warnings for it. For instance my validator gives other warnings too, e.g. from this submit page:

line 324 column 7 - Warning: entity "&nbsp" doesn't end in ';'

line 121 column 38 - Warning: <textarea> proprietary attribute "wrap"