CSS Properties: How to set the collapsing borders model for a table?
Solution:
HTML Code:
Explanation:
- This HTML document creates a table with borders around its cells.
- The CSS style block defines the style for the table, table cells (td), and table header cells (th).
- border-collapse: collapse; specifies that table borders should be collapsed into a single border.
- border: 1px solid red; sets a red solid border with 1px width for the table, td, and th elements.
- Inside the body, a table is defined with three rows (tr) and two columns (th and td).
- Table header cells (th) contain "First Name" and "Last Name" respectively.
- Table data cells (td) contain names like "Jack", "Bell", "Peter", and "Jhon".
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.