<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?
Each table row starts with a <tr> and ends with a </tr> tag.
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)
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With