2011-11-14 65 views
0

我想創建如下圖所示的XHTML文檔中的表格(如圖所示爲簡潔起見,僅相關部分):文件類型不允許「日」 /「TD」這裏

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

當我運行這個doc通過w3c驗證器,我得到了多種錯誤 - 文檔類型不允許'th'(或'td')在這裏。有人可以指出如何解決這個問題嗎?

+0

XHTML要求結束標記! –

回答

6

你不</tr></td>關閉您的任何<td><tr>標籤。此外,你錯過了>關閉所有<td>標籤。

+0

我很抱歉,我沒有意識到我編輯了你的答案而不是我的答案,因爲它們看起來很像。我已經回滾了。 – doctorless

+0

沒關係,歡呼聲。 – slugonamission

0

您沒有關閉您的<td><tr>標籤。

0

你沒有關閉你的標籤。對於每個<th><td>,您需要各自的</th></td>。這是它應該是什麼樣子:

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

你永遠關閉每個行的第一個<td>。更改

<tr><td class="rowLabel" 

<tr><td class="rowLabel"> 

而且,你必須關閉標籤的元素。表格如下:

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

您的文檔格式不正確。您需要關閉<th><td><tr>標籤....

例子:

<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> 
0

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