Re: Valid HTML / XHTML

On Fri, 12 Dec 2003 00:21:22 -0800, Terry Teague  
<terry_teague@users.sourceforge.net> wrote:

> At 9:22 AM +0100 12/11/03, Thomas Adams wrote:

>> Dear Terry, i recently have used tidy (Windows version from 12th July
>> 2003) to validate my HTML. Given is the DOCTYPE XHTML 1.0 Transitional  
>> in
>> my code, tidy validates its fine (it means succesfully). Then I have
>> changed the Doctype to HTML 4.01,tidy still validates the code as HTML
>> 4.01 Transitional, but using W3C-Online HTMLvalidator the validation for
>> HTML 4.01 fails (but for XHTML 1.0 Transitional the validation by W3C is
>> succesful), especially the XHTML-Notation for <col width="20%"/>
>> causes the errors. My question is, is my code still valid HTML 4.01 or  
>> do I have to do some rework on my html-code to validate at W3C as well.

> I have forwarded your EMail to the appropriate mailing lists for comment.

First of all, people should know that HTML Tidy does not actually validate  
HTML or XHTML. It tries to output valid code, but it is well known that it  
doesn't force the content to match the constraints imposed by the chosen  
Doctype.

The XHTML notation for empty elements like <img .. /> and <col .. /> is  
valid in the XML syntax used for XHTML, but invalid in the syntax used for  
HTML. It should be <img .. > and <col .. > instead. And this syntax is  
invalid for XML, which requires either an explicit closing tag (</img>),  
or the /> notation to close the start tag of the empty element.

So when going from XHTML to HTML, and the other way around, the closing of  
empty element like IMG, COL, META and LINK has to be adjusted. If Tidy  
doesn't do this (IIRC, Tidy only fixes it when going from HTML to XHTML,  
not the other way around), the author has to manually do this. A search an  
replace of "/>" with ">" should do the trick.


-- 
The Web is a procrastination apparatus:    | Rijk van Geijtenbeek
It can absorb as much time as              |  Opera Software ASA
is required to ensure that you             |  Documentation & QA
won't get any real work done.  - J.Nielsen | mailto:rijk@opera.com

Received on Friday, 12 December 2003 04:25:10 UTC