Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validation: "th start tag in table body."

Tags:

html

<table>
<thead>
 <th>Table Heading</th>
</thead>
<tbody>
 <tr>.....
</tbody>
</table>

When I try to validate this part of code, the validator returns this error:

 th start tag in table body.

The table template was copied from getbootstrap.com so I should assume it's valid. What's the problem here? Why is the validator returning this error, and how can I solve it?

like image 853
iTakeHome Avatar asked Feb 24 '15 22:02

iTakeHome


People also ask

Which tag starts and ends table?

Each table row starts with a <tr> and ends with a </tr> tag.

What is th in HTML?

The <th> tag defines a header cell in an HTML table. An HTML table has two kinds of cells: Header cells - contains header information (created with the <th> element) Data cells - contains data (created with the <td> element)


2 Answers

th is a table header cell - it needs to be within a table row (tr):

<table>
<thead>
 <tr>
  <th>Table Heading</th> 
 </tr>
</thead>
<tbody>
 <tr>.....
</tbody>
</table>
like image 108
D Stanley Avatar answered Oct 22 '22 08:10

D Stanley


The placement of your <th> element is correct aside from it needing to be placed inside a <tr> tag as well... as D Stanley mentioned.

This is the full HTML table formatting specified by W3C:

<table>
 <thead>
  <tr>
     <th>Month</th>
     <th>Savings</th>
  </tr>
 </thead>
 <tfoot>
  <tr>
     <td>Sum</td>
     <td>$180</td>
  </tr>
 </tfoot>
 <tbody>
  <tr>
     <td>January</td>
     <td>$100</td>
  </tr>
  <tr>
     <td>February</td>
     <td>$80</td>
  </tr>
 </tbody>
</table>

W3C

like image 44
jhawes Avatar answered Oct 22 '22 09:10

jhawes