Homunculus Reticulli
Homunculus Reticulli

Reputation: 68366

Document type does not allow 'th' / 'td' here

I am trying to create a table in an XHTML document shown below (only relevant parts shown for brevity sake):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head></head>
    <body>
      <table class="dataTable">
       <tfoot><tr><td class="tableFooter" colspan="4"><span>&copy;&nbsp;example.com</span></td></tr></tfoot>
       <tbody>
           <tr id = "firstRowHeader">
               <th class="rowLabel">&nbsp;
               <th class ="rowCol colHeader">ABC
               <th class ="rowCol colHeader">CDE
               <th class ="rowCol colHeader">EFG
           <tr><td class ="rowCategory" colspan ="4">Foo
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataDown">-0.01%
               <td class ="rowCol cellDataNoChange">0.09%
               <td class ="rowCol cellDataNoChange">717.79
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataUp">0.00%
               <td class ="rowCol cellDataNoChange">0.08%
               <td class ="rowCol cellDataNoChange">1,032.02
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataUp">-0.04%
               <td class ="rowCol cellDataNoChange">0.03%
               <td class ="rowCol cellDataNoChange">819.17
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataUp">-0.03%
               <td class ="rowCol cellDataNoChange">0.05%
               <td class ="rowCol cellDataNoChange">877.45
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataUp">-0.00%
               <td class ="rowCol cellDataNoChange">0.09%
               <td class ="rowCol cellDataNoChange">991.57
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataUp">-0.02%
               <td class ="rowCol cellDataNoChange">0.05%
               <td class ="rowCol cellDataNoChange">835.42
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataUp">0.00%
               <td class ="rowCol cellDataNoChange">0.05%
               <td class ="rowCol cellDataNoChange">1,002.40
           <tr><td class="rowLabel"
               <td class ="rowCol cellDataDown">-0.01%
               <td class ="rowCol cellDataNoChange">0.05%
               <td class ="rowCol cellDataNoChange">860.27
       </tbody>
      </table>

    </body>
</html>

When I run this doc through the w3c validator, I got several errors of the variety - Document type does not allow 'th' (or 'td') here. Can someone point out how to fix this?

Upvotes: 0

Views: 4935

Answers (6)

DefyGravity
DefyGravity

Reputation: 6011

<body>
  <table class="dataTable">
   <thead>
      <tr id = "firstRowHeader">
           <th class="rowLabel">&nbsp;</th>
           <th class ="rowCol colHeader">ABC</th>
           <th class ="rowCol colHeader">CDE</th>
           <th class ="rowCol colHeader">EFG</th>
      </tr>
   </thead>
   <tfoot>
     <tr>
       <td class="tableFooter" colspan="4"><span>&copy;&nbsp;example.com</span></td>
     </tr>
   </tfoot>
   <tbody>
       <tr>
       <td class ="rowCategory" colspan ="4">Foo</td>
       </tr>
       <tr><td class="rowLabel"></td>
           <td class ="rowCol cellDataDown">-0.01%</td>
           <td class ="rowCol cellDataNoChange">0.09%</td>
           <td class ="rowCol cellDataNoChange">717.79</td>
       </tr>
       <tr><td class="rowLabel"></td>
           <td class ="rowCol cellDataUp">0.00%</td>
           <td class ="rowCol cellDataNoChange">0.08%</td>
           <td class ="rowCol cellDataNoChange">1,032.02</td>
       </tr>
       <tr><td class="rowLabel"/>
           <td class ="rowCol cellDataUp">-0.04%</td>
           <td class ="rowCol cellDataNoChange">0.03%</td>
           <td class ="rowCol cellDataNoChange">819.17</td>
       </tr>
       <tr><td class="rowLabel"></td>
           <td class ="rowCol cellDataUp">-0.03%</td>
           <td class ="rowCol cellDataNoChange">0.05%</td>
           <td class ="rowCol cellDataNoChange">877.45</td>
       </tr>
       <tr><td class="rowLabel"/>
           <td class ="rowCol cellDataUp">-0.00%</td>
           <td class ="rowCol cellDataNoChange">0.09%</td>
           <td class ="rowCol cellDataNoChange">991.57</td>
       </tr>
       <tr><td class="rowLabel"/>
           <td class ="rowCol cellDataUp">-0.02%</td>
           <td class ="rowCol cellDataNoChange">0.05%</td>
           <td class ="rowCol cellDataNoChange">835.42</td>
       </tr>
       <tr><td class="rowLabel"></td>
           <td class ="rowCol cellDataUp">0.00%</td>
           <td class ="rowCol cellDataNoChange">0.05%</td>
           <td class ="rowCol cellDataNoChange">1,002.40</td>
       </tr>
       <tr><td class="rowLabel"></td>
           <td class ="rowCol cellDataDown">-0.01%</td>
           <td class ="rowCol cellDataNoChange">0.05%</td>
           <td class ="rowCol cellDataNoChange">860.27</td>
       </tr>
   </tbody>
  </table>

</body>

Upvotes: 0

slugonamission
slugonamission

Reputation: 9632

You're not closing any of your <td> or <tr> tags with </tr> or </td>. Also, you've missed a > off all of your <td> tags.

Upvotes: 7

Gabe
Gabe

Reputation: 50475

Your document is not well-formed. You need to close <th>, <td>, <tr> tags....

Example:

<tr id = "firstRowHeader">
   <th class="rowLabel">&nbsp;</th>
   <th class ="rowCol colHeader">ABC</th>
   <th class ="rowCol colHeader">CDE</th>
   <th class ="rowCol colHeader">EFG</th>
</tr>

Upvotes: 0

knittl
knittl

Reputation: 265141

You are never closing the first <td> in each row. Change

<tr><td class="rowLabel"

to

<tr><td class="rowLabel">

Also, you have to close your tag elements. A table looks like this:

<table>
<tr><th>header</th></tr>
<tr><td>content</td></tr>
</table>

Upvotes: 0

CassOnMars
CassOnMars

Reputation: 6181

You're not closing your tags. You need a respective </th> and </td> for each <th> and <td>. This is what it should look like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head></head>
    <body>
      <table class="dataTable">
       <tfoot><tr><td class="tableFooter" colspan="4"><span>&copy;&nbsp;example.com</span></td></tr></tfoot>
       <tbody>
           <tr id = "firstRowHeader">
               <th class="rowLabel">&nbsp;</th>
               <th class ="rowCol colHeader">ABC</th>
               <th class ="rowCol colHeader">CDE</th>
               <th class ="rowCol colHeader">EFG</th>
           </tr>
           <tr><td class ="rowCategory" colspan ="4">Foo</td></tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataDown">-0.01%</td>
               <td class ="rowCol cellDataNoChange">0.09%</td>
               <td class ="rowCol cellDataNoChange">717.79</td>
           </tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataUp">0.00%</td>
               <td class ="rowCol cellDataNoChange">0.08%</td>
               <td class ="rowCol cellDataNoChange">1,032.02</td>
           </tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataUp">-0.04%</td>
               <td class ="rowCol cellDataNoChange">0.03%</td>
               <td class ="rowCol cellDataNoChange">819.17</td>
           </tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataUp">-0.03%</td>
               <td class ="rowCol cellDataNoChange">0.05%</td>
               <td class ="rowCol cellDataNoChange">877.45</td>
           </tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataUp">-0.00%</td>
               <td class ="rowCol cellDataNoChange">0.09%</td>
               <td class ="rowCol cellDataNoChange">991.57</td>
           </tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataUp">-0.02%</td>
               <td class ="rowCol cellDataNoChange">0.05%</td>
               <td class ="rowCol cellDataNoChange">835.42</td>
           </tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataUp">0.00%</td>
               <td class ="rowCol cellDataNoChange">0.05%</td>
               <td class ="rowCol cellDataNoChange">1,002.40</td>
           </tr>
           <tr><td class="rowLabel"></td>
               <td class ="rowCol cellDataDown">-0.01%</td>
               <td class ="rowCol cellDataNoChange">0.05%</td>
               <td class ="rowCol cellDataNoChange">860.27</td>
           </tr>
       </tbody>
      </table>

    </body>
</html>

Upvotes: 0

SLaks
SLaks

Reputation: 887215

You didn't close your <td> and <tr> tags.

Upvotes: 0

Related Questions