Home CSS Properties border-collapse CSS border-collapse Property Definition
Definition and Usage The border-collapse property chooses how borders look inside a table: shared lines (collapse) or separate cell borders (separate).
Set it on the table (or inline-table), not on each cell. It is inherited. The initial value is separate. With separate, gaps come from border-spacing . With collapse, that spacing is ignored.
Standard-track. Not deprecated and not experimental. Both keywords are Baseline and widely available. In the collapsed model, inset paints like ridge and outset like groove.
Syntax
CSS Syntax border-collapse: separate | collapse | initial | inherit ;
Values
Property Values Value Description Try it separateDefault. Each cell keeps its own border. Use with border-spacing Try itcollapseAdjacent borders merge into one shared line Try itinitialResets to the default, separate Try itinheritTakes the parent’s border-collapse value Try it
Approach
How to Use border-collapse Build a real table, give cells a border, then pick the border model on the table.
Use a <table> with rows and cells (not a flex or grid fake table). Set a visible border on th and td. Set border-collapse on the table. If you chose separate and want gaps, add border-spacing . Piece Required? Role table / inline-tableYes Only these display types use this property Cell borders Yes (to see it) Without borders on cells, both keywords look empty border-collapseYes collapse or separate on the tableborder-spacingOptional Works only with separate
Try it
Live Preview Same table, same cell borders. Switch between collapse and separate to see shared lines versus distinct edges.
Code
CSS Examples Each snippet keeps CSS lean: a table, cell borders, and border-collapse. Use Try It Yourself for a live editor.
1. Collapse 2. Separate 3. Separate + spacing Example 1 — Collapsed Borders Merge adjacent cell borders into one shared grid line.
<style>
table {
border-collapse: collapse;
}
th,
td {
border: 1px solid black;
}
</style>
<table>
<tr>
<th>Name</th>
<th>Score</th>
</tr>
<tr>
<td>Ada</td>
<td>92</td>
</tr>
<tr>
<td>Lin</td>
<td>88</td>
</tr>
</table> How It Works Target the table. border-collapse: collapse belongs on table, not on each cell.Give cells a border. border: 1px solid black on th and td creates the lines to merge.Share the edges. Where two cells meet, the browser draws one shared border instead of two side by side.Skip spacing. border-spacing has no effect in the collapsed model.Example 2 — Separate Borders Keep each cell’s own border. This is the default model.
<style>
table {
border-collapse: separate;
}
th,
td {
border: 1px solid black;
}
</style>
<table>
<tr>
<th>Name</th>
<th>Score</th>
</tr>
<tr>
<td>Ada</td>
<td>92</td>
</tr>
<tr>
<td>Lin</td>
<td>88</td>
</tr>
</table> How It Works Choose the default model. separate is the initial value. Writing it makes the intent clear.Keep cell borders independent. Each cell draws its own full rectangle.Notice double edges. Where cells touch, you can see two borders meet instead of one shared line.Spacing is available. You can now use border-spacing to push cells apart.Example 3 — Separate with Spacing Leave borders separate, then add a gap between cells.
<style>
table {
border-collapse: separate;
border-spacing: 12px;
}
th,
td {
border: 1px solid black;
}
</style>
<table>
<tr>
<th>Name</th>
<th>Score</th>
</tr>
<tr>
<td>Ada</td>
<td>92</td>
</tr>
<tr>
<td>Lin</td>
<td>88</td>
</tr>
</table> How It Works Stay in separate mode. border-collapse: separate unlocks spacing.Set the gap. border-spacing: 12px puts space between every cell.Borders stay whole. Each cell still has its own border rectangle around its content.Collapse would ignore this. The same border-spacing does nothing if the table uses collapse. Edge Cases & Pitfalls If the table borders look wrong, one of these is usually why.
target Only tables use it Set border-collapse on table or inline-table. It does nothing on a normal div, even if the layout looks like a grid.
spacing border-spacing needs separateborder-spacing is ignored when borders are collapsed. Switch to separate first if you want gaps.
empty empty-cells is separate-onlyempty-cells controls whether empty cells show borders in the separate model. It does not apply when borders are collapsed.
styles inset / outset change when collapsedPer the CSS table model, collapsed borders map inset to ridge and outset to groove. Prefer solid for predictable study examples.
inherit It is inherited Unlike many border properties, border-collapse inherits. Nested tables pick up the parent value unless you override them.
Compatibility
Browser Support border-collapse is a browser table layout property . Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
border-collapse Chrome 1+, Firefox 1+, Safari 1.2+, Edge 12+, Internet Explorer 5+. Both separate and collapse are long-established.
Google Chrome 1+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 1.2+
Full support
Microsoft Edge 12+
Full support
Opera 4+
Full support
Samsung Internet 1+
Full support
Internet Explorer 5+
Full support border-collapse Widely supported
Bottom line: Safe for production tables in current browsers. Prefer solid borders when teaching, because some 3D border styles remap under collapse.
Remember
Key Takeaways Role: choose shared cell borders (collapse) or distinct cell borders (separate).
Where: set it on the table. It applies to table and inline-table only.
Initial value: separate. Unlike most border properties, this one is inherited.
Spacing: border-spacing works only with separate.
One line: border-collapse is the switch between one shared grid line and each cell keeping its own border frame.
Frequently Asked Questions What does the CSS border-collapse property do? It chooses whether adjacent table cell borders share one line (collapse) or stay as separate borders (separate). Set it on the table, not on each cell.
What is the default value of border-collapse? The initial value is separate. Each cell keeps its own border, and you can space cells with border-spacing.
When should I use collapse? Use collapse for clean data tables where shared edges should look like a single grid line. Use separate when you want gaps between cells.
Does border-collapse work on divs? No. It applies only to table and inline-table elements. Ordinary block boxes do not use the table border models.
Does border-spacing work with collapse? No. border-spacing only has an effect when border-collapse is separate. With collapse, spacing is ignored.
Which browsers support border-collapse? It is Baseline and widely available: Chrome 1+, Firefox 1+, Safari 1.2+, Edge 12+, and Internet Explorer 5+. It is a browser table layout property, not a Node.js feature.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion