RE: bug in handling </p> inside <table>

Rick Parsons wrote:

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

> I can see Stuart's point that P is not allowed in TABLE but if he is right
> in listing the only things allowed within a TABLE, why doesn't Tidy insert
> the TBODY where it is needed rather than let the browser imply it which
> always seems to be a dangerous thing to do?

To be precise, the *browser* isn't what implies it, the HTML 4 DTD does by the
rules of SGML (just as it "implies" HTML, HEAD, and BODY elements, by saying
that Start tags and End tags are both omissible and are to be inferred by the
content within in them).  For example, running a document containing

    <table>
      <tr><td>foo</td></tr>
    </table>

through sgmlnorm [1] will output a new document containing

    <TABLE>
     <TBODY>
        <TR><TD>foo</TD></TR>
      </TBODY>
    </TABLE>

XML doesn't allow you to infer anything of the sort (making an XML parser a lot
easier to write than an SGML parser).  So the XHTML 1.0 DTD is slightly
different:

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

Notice how it specifies that a table could have just one tbody **OR** one tr as
a direct child!

At any rate, you don't need to specify tbody either in HTML 4 (where it's
implied), or in XHTML 1 (where it's just optional).  Let the author decide.  In
either case, it shouldn't be considered "dangerous" to omit it -- by convention,
even the oldest browsers ignore elements they don't understand -- they ignore
tbody if it's there, and don't get upset if it isn't.

/Jelks


[1] http://www.jclark.com/sp/

Received on Tuesday, 25 July 2000 15:03:01 UTC