I want to make a table such that there is cellspacing (like you get when you make border-collapse: separate) only in the thead
section and not in the tbody
section.
I can make two tables like so
table.table1 {
border-spacing: 10px;
border-collapse: separate;
border: solid;
}
table.table1 th {
border: solid;
}
table.table2 {
border-spacing: 10px;
border-collapse: collapse;
border: solid;
}
table.table2 td {
border: solid;
}
<table class="table1">
<thead>
<tr>
<th> col1 </th>
<th> col2 </th>
<th> col3 </th>
<th> col4 </th>
</tr>
</thead>
</table>
<table class="table2">
<tbody>
<tr>
<td> val1 </td>
<td> val2 </td>
<td> val3 </td>
<td> val4 </td>
</tr>
<tr>
<td> val21 </td>
<td> val22 </td>
<td> val23 </td>
<td> val24 </td>
</tr>
</tbody>
</table>
But the widths might not match and then I would have to write a js script that matches the widths which is tedious and I do not think the right way to do it.
What I want is something like this
Please help