Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!?

like image 599
Robert Simenon Avatar asked Nov 30 '10 19:11

Robert Simenon


2 Answers

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.

like image 81
Oded Avatar answered Oct 07 '22 00:10

Oded


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

like image 3
armonge Avatar answered Oct 07 '22 00:10

armonge