I'm trying to fill black color between vertical cell spacing(columns) of a table in html but can't figure it out how to do it. Here is my code
table,
th,
td {
border-collapse: separate;
border-spacing: 2px;
border-style: solid;
border-width: thin;
}
<table>
<tr>
<th>Heading One</th>
<th>Heading Two</th>
<th>Heading Three</th>
</tr>
<tr>
<td>Apple</td>
<td>10</td>
<td>$1.0</td>
</tr>
<tr>
<td>Mango</td>
<td>12</td>
<td>$2.0</td>
</tr>
</table>
Best way to do this would be to add a background color to the table and a foreground color to the fields. See below
table, th, td
{
border-collapse: separate;
border-spacing:2px;
border-style: solid;
border-width:thin;
}
table{background:#000;}
tr{background: #fff;}
<table>
<tr><th>Heading One</th>
<th>Heading Two </th>
<th>Heading Three </th>
</tr>
<tr>
<td>Apple</td>
<td>10</td>
<td>$1.0</td>
</tr>
<tr>
<td>Mango</td>
<td>12</td>
<td>$2.0</td>
</tr>
</table>
The space between the cells is the table. You change the background of the table in the same way as any other element.
Watch out, the default background colour of the table cells is transparent.
table,
th,
td {
border-collapse: separate;
border-spacing: 2px;
border-style: solid;
border-width: thin;
}
table {
background-color: black;
}
td, th {
background-color: white;
}
<table>
<tr>
<th>Heading One</th>
<th>Heading Two</th>
<th>Heading Three</th>
</tr>
<tr>
<td>Apple</td>
<td>10</td>
<td>$1.0</td>
</tr>
<tr>
<td>Mango</td>
<td>12</td>
<td>$2.0</td>
</tr>
</table>
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