3
Syntactically it is likely that anything is possible, but semantically zero or one is allowed thead
and zero or several tbody
.
console.log(document.querySelectorAll("table tbody").length)
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
padding: 5px 10px;
}
<table>
<thead>
<tr>
<th>Coluna 1</th>
<th>Coluna 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Valor 1</td>
<td>Valor 2</td>
</tr>
<tr>
<td>Valor 3</td>
<td>Valor 4</td>
</tr>
</tbody>
<tbody>
<tr>
<td>Valor A</td>
<td>Valor B</td>
</tr>
<tr>
<td>Valor C</td>
<td>Valor D</td>
</tr>
</tbody>
</table>
Citing the MDN (source)
Permitted content (in this order)
- an element
<caption>
optional ,- zero or more elements
<colgroup>
,- an element
<thead>
optional,- any of the following:
- zero or more elements
<tbody>
- one or more elements
<tr>
- an element
<tfoot>
optional
How do you know you have tbody and thead in this example image if you have code? i don’t really know the correct semantics, but, I think (achismo) that can only have one for each
<table>
– novic
although it has table layout and semantically it is correct to use a table tag here, it does not limit you, you can do this with div for example
– Ricardo Pontual