Re: HTML 4.01 DTD

Robert van Loenhout <r.vanloenhout@greenvalley.nl> wrote:
> <!ELEMENT TABLE - -
> (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
> <!ELEMENT CAPTION  - - (%inline;)*     -- table caption -->
> <!ELEMENT THEAD    - O (TR)+           -- table header -->
> <!ELEMENT TFOOT    - O (TR)+           -- table footer -->
> <!ELEMENT TBODY    O O (TR)+           -- table body -->
> <!ELEMENT COLGROUP - O (COL)*          -- table column group -->
> <!ELEMENT COL      - O EMPTY           -- table column -->
> <!ELEMENT TR       - O (TH|TD)+        -- table row -->
> <!ELEMENT (TH|TD)  - O (%flow;)*       -- table header cell, table data
> cell-->
> 
> This definition seems to me that a TR tag is not allowed to be a direct
> child of
> a TABLE tag. This surprised me... Also because when I validate a 4.01
> document
> with the w3c validator it says it is valid.
> 
> Could someone explain this?

As you quoted, the TABLE element MUST contain one or more TBODY elements,
and both of start tag and end tag of TBODY are omissible.

That is, in HTML 4.01

  <TABLE>
    <TR>...</TR>
    <TR>...</TR>
  </TABLE>

is equal to 

  <TABLE>
    <TBODY>
      <TR>...</TR>
      <TR>...</TR>
    </TBODY>
  </TABLE>.

So it is valid, to be sure.

# In addition, in the case of XHTML table, the table element is allowed
# to contain the tr elements directly.

Regards,
-- 
Satoshi ISHIKAWA / webmaster@satoshii.org
http://www.satoshii.org/markup/

Received on Friday, 16 April 2004 05:33:18 UTC