[wp-hackers] XHTML Strict Mode

Michael Leuchtenburg michael at slashhome.org
Fri Aug 6 00:53:16 UTC 2004


I agree that your other examples are all obviously broken, but I contest 
the following:

Scott Reilly wrote:
> 3.) ------------------------------
> 
> <b>aaaa<div>bbb</div><i>ccc<hr />
> 
> yielded:
> 
> <b>aaaa</b><div>bbb</div><i>ccc<hr />
> </i>
> 
> (I feel balancing should close tags as late as possible; so for this, since 
> there is nothing in this example to prevent the <b> from being closed at the 
> end:
> <b>aaaa<div>bbb</div><i>ccc<hr /></i></b>

There is, in fact. According to the XHTML 1.0 Strict DTD, the b element 
can only contain elements in the Inline class:
<!ELEMENT b %Inline;>

div is a block element, and so can't be contained in b.

Of course, if you just want to do pure balancing, then I agree with your 
proposed correct results. If you want to try to correct other broken 
XHTML, then more work is needed. I don't think it would be too much 
difficulty to differentiate between inline and block level elements, at 
least: doing things like avoiding an anchor tag inside another and other 
illegal results may be more work than is worthwhile. Assuming the user 
isn't a complete HTML ass seems reasonable, especially since the worst 
result is that the output is not XHTML compliant.

-- michael



More information about the hackers mailing list