2012-10-24 20 views
0

我使用的HTML標籤構建一個簡單的表格。源代碼是這樣的:Misterious行HTML表頭

<table class="tableClass"> 
    <thead> 
     <tr> 
      <th>Column Header</th> 
      <th>Column Header</th> 
     <tr> 
    </thead> 
    <tbody>  
      <tr> 
       <td>Column Data</td> 
       <td>Column Data</td> 
      </tr>  
    </tbody> 
</table> 

當我嘗試在頭部分瀏覽器中的表似乎是一個空行。我已經在Firefox和Chrome嘗試過了,調試器輸出這樣的:

<table class="tableClass"> 
     <thead> 
      <tr> 
       <th>Column Header</th> 
       <th>Column Header</th> 
      <tr> 
      <tr></tr> 
     </thead> 

那空行不會在代碼的任何地方出現,但似乎調試器找到它。任何想法可能來自哪裏?它與表格樣式有關嗎?

回答

1

關閉<tr><thead>你不關閉<tr>只是讓一個新的。

<table class="tableClass"> 
    <thead> 
     <tr> 
      <th>Column Header</th> 
      <th>Column Header</th> 
     <tr> <!-- NOT CLOSED! --> 
    </thead> 
    <tbody>  
      <tr> 
       <td>Column Data</td> 
       <td>Column Data</td> 
      </tr>  
    </tbody> 
</table> 

如果您驗證您的HTML,您將避免這些錯誤。

+0

我的錯。謝謝! –

1

你沒有在你的<thead>

<thead> 
    <tr> 
     <th>Column Header</th> 
     <th>Column Header</th> 
    </tr> <!-- here --> 
</thead> 
0
<table class="tableClass"> 
    <thead> 
     <tr> 
      <th>Column Header</th> 
      <th>Column Header</th> 
     <tr> //NOT CLOSED 
    </thead> 

關閉錶行:)