W3C home > Mailing lists > Public > w3c-wai-ig@w3.org > October to December 2004

Re: Question about tables

From: David Woolley <david@djwhome.demon.co.uk>
Date: Tue, 30 Nov 2004 22:24:04 +0000 (GMT)
Message-Id: <200411302224.iAUMO5s19362@djwhome.demon.co.uk>
To: w3c-wai-ig@w3.org

> Ok, I have a question about the use of the elements THEAD, TBODY  and TFOOT.
> In the xhtml-dtd the element TABLE is described as followed:

Please note that Internet Explorer doesn't understand XHTML, although
it is the most commonly used browser, so if you are forced to author
in XHTML, you must restrict yourself to XHTML 1.0 and apply the 
compatibility rules from the appendices, to allow reasonable error
recovery in HTML 4.x browsers.  This is a case where those rules
are important.

In my view, documents for the public web should be authored in the
earliest version of HTML that will do the job, and no later than HTML

> <!ELEMENT table
>      (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>

Here, you have to understand that this is trying to simulate the
behaviour of HTML, but without the use of the SGML optional tags, which
are dropped from XML.  In HTML, both start and end tags for TBODY
are optional, and the parser is expected to infer TBODY around any
consecutive run of TR immediately below TABLE.  To allow XHTML 
tbody, tr and table to work in a similar way, tr is an explicit alternative
to tbody.  Note that this doesn't allow all the combinations allowed
by HTML, as <tbody>...</tbody><tr>...</tr> is not allowed.

More importantly, the TBODY is actually in the document parse tree for
HTML, so is visible to scripting and style sheet selectors, but tbody
is only in the XHTML parse tree if there explicitly.  This means that,
if you use tr in XHTML, real XHTML browsers will likely style and script
it differently from HTML browsers tolerating XHTML.  That's why the
compatibility rules require tbody to be explicit in XHTML.

> In my opinion, none of the elements THEAD, TBODY  and TFOOT dependent on

I assume you meant thead, tbody and tfoot.

> another element. I can use every element as "stand alone" element. On some
> websites (for example: w3c-schools -> xhtml) it is said, that every element
> of those three elements is used with each other of those three elements: The
> three Elements can only be used all together and not "stand alone". 

That's not true, but you must have either a tbody or tr in XHTML and you
must have a TBODY in HTML.

> What is the correct use of the elements THEAD, TBODY  and TFOOT?

The actual data should be in one or more tbody elements (which may have
implied tags in HTML, and needs to be explicit for XHTML conforming to
the compatibility rules).  Column headers should normally be in the thead
element, and any column footer labels (but not totals) should be in a
tfoot element.  thead corresponds to using Table | Header in Microsoft
Word.  Most real tables really ought to have both thead and tbody.
Received on Tuesday, 30 November 2004 22:24:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 20:36:23 UTC