Example Code:
Name |
Address |
Age |
---|---|---|
Jill |
Switzerland |
65 |
Eve |
Jamaica |
23 |
John |
Denmark |
23 |
table {
border-spacing: 5px;
}
td {
padding: 5px;
}
border-spacing
Property to Specify the Vertical and Horizontal Spacing in CSSWe can use the border-spacing
property to specify the horizontal and vertical spacing between the borders of the cells in the table. In the previous example, we applied horizontal spacing. Here, we will apply both spacings. We can specify two values for the border-spacing
property. The first resembles the horizontal spacing, and the second resembles the vertical spacing. We can apply this method in the table created above.
For example, select the table
tag and set border-spacing
to 8px
and 5px
. It will create the horizontal spacing of 8px
and the vertical spacing of 5px
.