In my table, I have 2 header rows and multiple body rows. To create a spacing of 10 pixels between body rows, I used the following CSS:
border-collapse: separate;
border-spacing: 10px;
However, this also affected the spacing in the header rows, which I want to have no space between them. In my HTML code snippet, you can see that I am setting the border-spacing property for the entire table:
table td {
background-color: lime;
padding: 12px
}
table th {
background-color: red;
padding: 12px;
}
table {
border-collapse: separate;
border-spacing: 10px;
}
<table>
<thead>
<tr>
<th>head 1</th>
<th>head 1</th>
<th>head 1</th>
</tr>
<tr>
<th>head 2</th>
<th>head 2</th>
<th>head 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
</tbody>
</table>
If you view the fiddle here, you will see that there is space between the first and second header rows. Is there a way to remove this space without affecting the body rows? I attempted to apply border-spacing only to the body rows, but it seems to only work at the table level. Any suggestions or solutions would be appreciated.