CSS Properties: How to set the border-spacing for a table?
Solution:
HTML Code:
Explanation:
- The HTML document structure includes essential elements such as html, head, title, style, and body.
- CSS styling is applied to tables with class xyz1 and xyz2, setting their border-collapse behavior to separate, which ensures spacing between table cells.
- The border-spacing property is used to specify the spacing between table cells, with 5px for xyz1 and 5px horizontal spacing and 20px vertical spacing for xyz2.
- The color of the table border is set to #22CF64 for both tables.
- Two tables are created with different classes and borders, demonstrating the effect of different border-spacing configurations.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.