Re: It isn't a standard if it has hidden rules for historical reasons.

Philip Taylor (Webmaster, Ret'd) wrote:

> Aaron Oxford wrote:
[...]
>> Now what you're saying is that it was actually invalid for me to OPEN
>> that UL, not for me to later close it.
>
> No, absolutely not : it was perfectly valid for you to open the <UL>,
> but in so doing, you forced the <P> to close.

In syntactic terms, yes. In terms of how people think and what they wish to 
do, the mistake was the idea of including a UL element in a P element. It's 
a natural idea, but ever since the dawn of HTML up to the foreseeable future 
(the HTML5 drafts), the P element has been "text-level" or "inline" data 
only. And this is reflected in the formal syntax so that all "block-level" 
descendants like UL are forbidden.

This conflicts with a common typographic notion of a paragraph: a paragraph 
may contain a list, e.g. so that a sentence continues as a list, so that the 
list items are grammatically parts of the sentence. Although "P" is short 
for "paragraph", "P" doesn't really _mean_ a paragraph, just a related 
concept.

> [...] you simply
> can't have a <UL> as a direct descendant of a <P>, because both
> are block-level elements and these do not nest.

Not quite so. You can't have a UL as a direct (or indirect) descendant of a 
P, simply because the HTML syntax says so. Block-level elements often nest; 
for example, DIV elements may be nested as much as you like, UL may contain 
P (though not directly - there must be an LI element at intermediate nesting 
level), etc.

>  All block-level elements (<P>, <UL>, <DIV>,
> ...) are basically <P>-like, and when one follows another, the browser
> will insert a certain amount of white space to indicate the boundary.

No, the default rendering of DIV has no margins (the specs say this more or 
less clearly), and in practice TABLE lacks default margins too.

> But it's pretty trivial to suppress it in CSS.
[...]
> P, UL {margin-top: 0; margin-bottom: 0; padding-top: 0;
> padding-bottom: 0}

We're way off-topic now, but I'd like to comment that it's that trivial in a 
trivial case. In a general case, where you have P and UL elements all around 
and you don't want to remove _all_ of their margins, you need something more 
elaborated.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/ 

Received on Thursday, 10 March 2011 06:05:47 UTC