Tables require a TBODY

brianiac on 2006-03-14T19:37:29

Special note to the VisualStudio Team, the IE team, and all web coders: Check the spec, the table tag *does not* contain tr tags, and hasn't since 1999! Tables must contain tbody tags (and optionally thead and tfoot tags), and that's where the tr tags go.


Don't be so sure...

jk2addict on 2006-03-14T19:59:04

While I agree that the DTD is somewhat ambigous about it, a little further down the page doesn't agree with your findings...

http://www.w3.org/TR/html4/struct/tables.html#h-11.2.5

Ambiguous?

brianiac on 2006-03-14T21:20:51

<!ELEMENT TABLE - -
          (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>


That doesn't look ambiguous at all. If it's wrong (as suggested by the example, and the XHTML 1.0 and 1.1 DTDs), why has it never been fixed? I mean, that is a major technical error.

Ah...

brianiac on 2006-03-14T21:54:44

Start tag optional. *Sheesh*

But TBODY is optional...

bart on 2006-03-14T20:25:52

Checking the same page, you can see the following for TBODY:
<!ELEMENT TBODY    O O (TR)+           -- table body -->

Start tag: optional, End tag: optional
That would appear to mean, if I don't read it wrongly, that you can drop explicit mention of TBODY, so that embedded TR tags are in an implied TBODY, if you don't mention one.

Re:But TBODY is optional...

brianiac on 2006-03-14T21:53:09

I thought that XHTML 1.0's reliance on the HTML 4.0 spec was a problem here, but C.11. #2 seems to address this specifically:

User agents that access XHTML documents served as Internet media types text/xml, application/xml, or application/xhtml+xml can also use the XML DOM. Elements and attributes will be returned in lower-case. Also, some XHTML elements may or may not appear in the object tree because they are optional in the content model (e.g. the tbody element [emphasis added] within table). This occurs because in HTML 4 some elements were permitted to be minimized such that their start and end tags are both omitted (an SGML feature). This is not possible in XML. Rather than require document authors to insert extraneous elements, XHTML has made the elements optional. User agents need to adapt to this accordingly. For further information on this topic, see [DOM2]

Bug.

Juerd on 2006-03-14T20:41:32

It's a bug in the spec. (And the bug is not present in xhtml's dtd.)