|
Posted by Patient Guy on February 13, 2005, 12:17 pm
Please log in for more thread options
In my reading of the Strict and Transitional DTD for HTML 4.0, the table
row (TR) elements are contained within table section elements: THEAD,
TFOOT, and TBODY.
The table section elements are the defined contents of the TABLE element.
The TR element is not defined as an "immediate" or "direct" contained
element of TABLE.
Given that
i. the use of the table section elements is optional, but that
ii. TBODY is implicit when no table section elements are specified with an
HTML table,
what does an HTML parsing agent (browser) do when tree-building from a
TABLE node and it encounters a TR element without having encountered any
table section element?
Does it:
1. append the TR element node to the TABLE node?
OR
2. examine for the presence of a table section node, and failing to find
one instantiated, perform the following steps in this order:
a. instantiate a TBODY element node
b. append it to the TABLE node
c. create the TR element node
d. append the TR node to the TBODY node
e. continue reading the HTML and develop the table according the
specification?
Corrections to my reading of the HTML DTD are warmly appreciated.
|
|
Posted by Roy Schestowitz on February 13, 2005, 12:28 pm
Please log in for more thread options
Patient Guy wrote:
>
>
> In my reading of the Strict and Transitional DTD for HTML 4.0, the table
> row (TR) elements are contained within table section elements: THEAD,
> TFOOT, and TBODY.
>
> The table section elements are the defined contents of the TABLE element.
> The TR element is not defined as an "immediate" or "direct" contained
> element of TABLE.
>
> Given that
>
> i. the use of the table section elements is optional, but that
> ii. TBODY is implicit when no table section elements are specified with an
> HTML table,
>
> what does an HTML parsing agent (browser) do when tree-building from a
> TABLE node and it encounters a TR element without having encountered any
> table section element?
>
> Does it:
>
> 1. append the TR element node to the TABLE node?
>
> OR
>
> 2. examine for the presence of a table section node, and failing to find
> one instantiated, perform the following steps in this order:
> a. instantiate a TBODY element node
> b. append it to the TABLE node
> c. create the TR element node
> d. append the TR node to the TBODY node
> e. continue reading the HTML and develop the table according the
> specification?
>
>
> Corrections to my reading of the HTML DTD are warmly appreciated.
Sources I read say that <tbody> and the like are mandatory. The indentation
and purification tool called 'tidy' insists on it too.
However, W3C validators do not insist on it (at least XHTML, but I think
others too from what I can recall). The question is then whether you want
your page to validate safely or also remain a stickler. Then again,
validators evolve... just make sure you specify a version number which
works.
Roy
--
Roy Schestowitz
http://schestowitz.com
|
|
Posted by Michael Winter on February 13, 2005, 2:01 pm
Please log in for more thread options [Follow-up ignored: cross-posted to clj, ah and ciwah. Follow-ups set
to ciwah]
Roy Schestowitz wrote:
> Patient Guy wrote:
>
>> The TR element is not defined as an "immediate" or "direct"
>> contained element of TABLE.
In other words, a not a child but a descendant.
[snip]
>> what does an HTML parsing agent (browser) do when tree-building
>> from a TABLE node and it encounters a TR element without having
>> encountered any table section element?
Well it depends. Will it encounter any table section elements?
If not, presumably an implementation will create a TBODY element and
place all table rows inside that element. For example, this is what an
implementation should do should a document dynamically create a TABLE
element via the DOM and insert a new row without first creating a TBODY.
If table section elements will be encountered, then we're talking
error correction and the user agent is likely to do anything.
[snip]
> Sources I read say that <tbody> and the like are mandatory.
Yes, a TBODY element is mandatory, however its start and end tags are
optional.
"The TBODY start tag is always required except when the table
contains only one table body and no table head or foot
sections."
In the latter case, the table body should be created implicitly.
[snip]
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
|
|
Posted by Jukka K. Korpela on February 13, 2005, 7:16 pm
Please log in for more thread options
> Yes, a TBODY element is mandatory, however its start and end tags are
> optional.
Yes.
> "The TBODY start tag is always required except when the table
> contains only one table body and no table head or foot
> sections."
I was bit surprised at finding that statement in the HTML specification, at
http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2.3
I'm pretty sure it's an oversight. It's debatable whether it is to be read
as a normative statement, i.e. whether a document conforming to the HTML
4.01 specification must obey it.
In any case, it expresses a requirement that is not derivable from the DTD.
The following piece of markup violates the statement but is valid:
<table>
<thead>
<tr><th>foo
</thead>
<tr><td>bar
</table>
So is the following (with two TBODY elements, the first with both start and
end tags implied):
<table>
<tr><td>bar
<tbody>
<tr><td>bar too
</table>
It's rather perverse, but valid markup.
--
Yucca, http://www.cs.tut.fi/~jkorpela/ Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
|
|
Posted by Michael Winter on February 13, 2005, 8:24 pm
Please log in for more thread options Jukka K. Korpela wrote:
[snipped specification quote]
> I was bit surprised at finding that statement in the HTML
> specification, at
> http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2.3
Thank you. As a rule, I always provide a link to content I quote or
reference, but I forgot to in my last post.
> [...] It's debatable whether it is to be read as a normative
> statement [...]
I suppose it is, but it's quite possible it is normative. The
statement prior to my quote is (emphasis is my own):
"The following summarizes which tags are *required* and which
may be omitted:"
Then again, I must say I'm confused when the key words listed in
section 4[1] apply (of which one is "required"). For example, when
describing the TITLE element[2], the word "must" is emphasised, but I
don't think other key words are anywhere else in the specification.
> In any case, it expresses a requirement that is not derivable from
> the DTD.
But there are other conditions that are stated only in the prose and
cannot be indicated by the DTD (none spring to mind at the moment,
though). I'm not familiar enough with SGML to know so perhaps you
could tell me if it would be feasible to define the constraint.
[snip]
Mike
References:
[1] <URL:http://www.w3.org/TR/html4/conform.html> [2] <URL:http://www.w3.org/TR/html4/struct/global.html#h-7.4.2>
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
|
| Similar Threads | Posted | | Table Element Focus events | February 21, 2005, 8:47 am |
| Element "P" IS open! | March 18, 2005, 7:22 am |
| Root element specified by DTD ? | June 2, 2006, 5:16 am |
| Possibly OT - would like to have an element back | March 26, 2005, 9:46 pm |
| Please help me find my unclosed element | January 5, 2006, 10:30 pm |
| Element "x" undefined when using validator | February 10, 2006, 2:16 pm |
| acclerator key with input element | March 23, 2006, 8:14 am |
| layout element positioning using CSS... | June 7, 2006, 4:04 pm |
| Form element with no tab index | February 17, 2007, 3:44 pm |
| xhtml: adding ELEMENT to dtd | September 28, 2007, 1:00 pm |
|