Pops wrote:
Sorry if I am a dounce, but I still don't see the invalidity of it.

Do you have an example to show how this is incorrect in relationship
to anything (DOM? CSS?) ?

ul and ol elements may only have li elements as children, that's written in the DTD.
http://www.w3.org/TR/html401/struct/lists.html#h-10.2

Use the W3C validator to see that this is invalid.
http://validator.w3.org/

If there's no li element but a ul, the parser will most likely wrap a li element internally around the ul resulting in a valid DOM. In other words that invalid construct will work (as text/html!) because the browser's tag soup parser attempts to fix all the bugs that an HTML author may have made. Shouldn't try that with XHTML as XML, where you'll get draconian error handling aka the yellow screen of death.

Consider another example that should make it clearer:

<p>
the author intends to nest a ul in the p
<ul>
...
</ul>
</p>

The following selector will fail:

$('p>ul')

Why? Because the browser implicitely closes the p element before the ul starts - there is simply no ul inside the p:

<p>...</p>
<ul>
...
</ul>

This is especially because a closing tag is not required for a p element in HTML (not in XHTML).

Another example: you can also leave away the body tags, but that doesn't mean that the browser won't create a body element implicitely.


The technical problem I see using this wrapping method is that you get
redundant (bubbling?) events.  Is that right?

Don't know. The technical problem to me is that you shouldn't script on top of an invalid DOM as you won't get predictable behaviour, especially cross browser.




--Klaus

Reply via email to