I have an HTML table. I need to have spacing between the table columns, but not the table rows.
My table columns also have border around them:
<table>
<tr>
<td style="padding:0 15px 0 15px;">hello</td>
<td style="padding:0 15px 0 15px;">world</td>
<td style="padding:0 15px 0 15px;">how</td>
<td style="padding:0 15px 0 15px;">are</td>
<td style="padding:0 15px 0 15px;">you?</td>
</tr>
<tr>
<td style="padding:0 15px 0 15px;">hello</td>
<td style="padding:0 15px 0 15px;">world</td>
<td style="padding:0 15px 0 15px;">how</td>
<td style="padding:0 15px 0 15px;">are</td>
<td style="padding:0 15px 0 15px;">you?</td>
</tr>
</table>
Css
table td{
border : 1px solid black;
border-spacing: 1em 0;
}
fiddle
If I use the cellspacing css property it does it between both rows and columns.
There is no cellspacing CSS property.
The property is called border-spacing and …
The lengths specify the distance that separates adjoining cell borders. If one length is specified, it gives both the horizontal and vertical spacing. If two are specified, the first gives the horizontal spacing and the second the vertical spacing. Lengths may not be negative.
… takes two values.
So:
border-spacing: 1em 0;
table {
border-collapse: separate;
border-spacing: 1em 0;
}
https://www.w3schools.com/cssref/pr_border-spacing.asp
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