Why does this html table definition not validate?
I'm getting this W3C HTML validation error:
开发者_如何转开发end tag for "table" which is not finished
for this code:
<table id="myTable">
</table>
This is my DOCTYPE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
I thought that table definition was perfectly fine!?
If you look at the XHTML 1.0 Strict DTD, it specifies that a table requires at least one of TR
OR TBODY
:
<!ELEMENT table
(caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>
<!ELEMENT caption %Inline;>
<!ELEMENT thead (tr)+>
<!ELEMENT tfoot (tr)+>
<!ELEMENT tbody (tr)+>
<!ELEMENT colgroup (col)*>
<!ELEMENT col EMPTY>
<!ELEMENT tr (th|td)+>
<!ELEMENT th %Flow;>
<!ELEMENT td %Flow;>
The TR
, in its turn, requires at least one of TH
or TD
.
The +
sign after an element name means it should appear at least once.
I believe there should be a tr and td tags inside a table to validate. It's the same when you close a head tag without including a title tag
A XHTML 1.0 table is required to have at least a tbody
or a tr
child. See the DTD, specifically the table element:
<!ELEMENT table
(caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>
Note the last part.
Take a look at http://validator.w3.org/docs/errors.html
73: end tag for X which is not finished
Most likely, you nested tags and closed them in the wrong order. For example <p><em>
.
</p>
is not acceptable, as <em>
must be closed before <p>
. Acceptable nesting is:
<p><em>...</em></p>
Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the element must contain a child element, lists require appropriate list items (<ul>
and <ol>
require <li>
; <dl>
requires <dt>
and <dd>
), and so on.
You need at least one <tr>
inside your table.
精彩评论