W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2007

[whatwg] P element's content model restrictions

From: Leif Halvard Silli <lhs@malform.no>
Date: Tue, 29 May 2007 20:02:53 +0200
Message-ID: <144d3d35a8e2d8fda48182ed7362b77e@10013.local>
On 2007-05-29 07:18:09 +0200 Martin Payne <martin-bulkmail at martinpayne.co.uk> wrote:

> Leif Halvard Silli wrote:
>> I'd like to question these restricions. I think that at the very least, 
>> TABLE should be allowed inside the P element. The reason is that MSIE (I 
>> tested version 6 and 7) accept TABLE in P, regardless of whether it is in 
>> Quirks-Mode or in Standards-Mode. Even Firefox-Opera-Safari (FirOpSa) allow 
>> TABLE inside P - allthough they only do so when in Quirks-Mode.
>> 
> 
> When would it ever make sense to do this though? Surely you would never want 
> to put a table inside a paragraph, because tables and paragraphs are two 
> totally different things. I also can?t see why you would put a paragraph 
> inside a paragraph?surely it should either just be one paragraph, or be two 
> completely separate paragraphs.

Hi Martin, I thought the whole ?real-world? would come upon me for suggesting this, but you are the only critical voice so far. Many thanks to the suppor from Benjamin as well. I would love to hear from ?browser vendors? also. When the spec quotes ?historical reasons?, then I suppose they mean ?real world? or something. But then please note that IE treats TABLE within P ?better? in standards-mode than in quirks-mode. :-) (Fewer inheritable styles get inherited by TABLE in quirks-mode than in standards-mode.) 

First, you do realize that what I suggested is *in line* with what the proposed specification permits for XHTML5? (Actually, I think the spec should make it much clearer that it is. For instance, it could start with clearly stating that section 8 about ?The HTML syntax? only deals with HTML5, and not with the syntax of XHTML5. Again - shoot me if I am wrong.)

Second, I think TABLE inside P would be usefull - often (and not just sometimes). Let's say you wanted a left border on all P-elements. Or that you wanted to enumerate all P-elements (all paragraphs).

| Para with table
|     
| +---------+
| | TH | TH |
| |----|----+
| | TD | TD |
| +---------+
|            
| End of para.

If P have any semantics, then this example shows very well why the TABLE _should_ be insid the P. The alternatives are two P-elements and a TABLE in the middle of them. Or simply no paragraph at all - a DIV. But with two P-elements, then if you want to enumerate all the P-elements via CSS, you will get one numbers per P = 2 numbers each time you have a TABLE, instead of just 1 number. There is of course a plethora of workarounds ... But it would be better to make the language as simple as possible for authors. That will in itself prevent much ?invention/workaround/hacks? - which browser vendors then will have to ?quirk? with.

Academical documents is also something that would benefit. Do you think a person who just want to write a thesis-like document in HTML would think that he in fact cannot have have lists, tables and blockquots within paragraphs? And in this context, I will also mention e.g. Prince XML, the XML formatter, which can also format HTML. What if I make something that prints well in Prince and want to put it online - things starts to break down?

Yet another thing, is that if you may place lists and table inside P-elements, then CSS becomes simpler. You use your energy the right CSS for the P-elements, so they constitute a column or something. Then you stuff your TABLE elements inside the P-elements. And so TABLE will be placed relative to the P - and not relative to the parent of P. Simple. Logical.

The fact that the above is possible in XHTML5, but not in HTML5 gives XHTML5 an advantage. But it was my impression that the WHATwg wants to ?lift? the status of HTML to a higher level - if I may put it that way. 

The HTML5 proposal has a section where it discusses how paragraphs are represented in HTML. <http://www.whatwg.org/specs/web-apps/current-work/#paragraphs>. It does not say that TABLE can represent a paragraph. Or that DIV can. But the effect of not being able ot place TABLE inside P, is that either DIV or TABLE will be used as paragraphs. And it also means that sometimes, things that really are one paragraph, will look as if it is 2 or 3 paragraphs. I.e. we cannot trust that the P represent what was meant to be expressed.
-- 
leif halvard silli
Received on Tuesday, 29 May 2007 11:02:53 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:55 UTC