CSS border-collapse Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

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.

CSS Syntax

syntax.css
border-collapse: separate | collapse | initial | inherit;

Property Values

ValueDescriptionTry it
separateDefault. Each cell keeps its own border. Use with border-spacingTry it
collapseAdjacent borders merge into one shared lineTry it
initialResets to the default, separateTry it
inheritTakes the parent’s border-collapse valueTry it

How to Use border-collapse

Build a real table, give cells a border, then pick the border model on the table.

  1. Use a <table> with rows and cells (not a flex or grid fake table).
  2. Set a visible border on th and td.
  3. Set border-collapse on the table.
  4. If you chose separate and want gaps, add border-spacing.
PieceRequired?Role
table / inline-tableYesOnly these display types use this property
Cell bordersYes (to see it)Without borders on cells, both keywords look empty
border-collapseYescollapse or separate on the table
border-spacingOptionalWorks only with separate

Live Preview

Same table, same cell borders. Switch between collapse and separate to see shared lines versus distinct edges.

Cell borders stay 2px solid. Only the table model changes.

Table
NameScore
Ada92
Lin88

border-collapse: collapse

CSS Examples

Each snippet keeps CSS lean: a table, cell borders, and border-collapse. Use Try It Yourself for a live editor.

Example 1 — Collapsed Borders

Merge adjacent cell borders into one shared grid line.

CSS
<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>
Try It Yourself

How It Works

  1. Target the table. border-collapse: collapse belongs on table, not on each cell.
  2. Give cells a border. border: 1px solid black on th and td creates the lines to merge.
  3. Share the edges. Where two cells meet, the browser draws one shared border instead of two side by side.
  4. 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.

CSS
<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>
Try It Yourself

How It Works

  1. Choose the default model. separate is the initial value. Writing it makes the intent clear.
  2. Keep cell borders independent. Each cell draws its own full rectangle.
  3. Notice double edges. Where cells touch, you can see two borders meet instead of one shared line.
  4. 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.

CSS
<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>
Try It Yourself

How It Works

  1. Stay in separate mode. border-collapse: separate unlocks spacing.
  2. Set the gap. border-spacing: 12px puts space between every cell.
  3. Borders stay whole. Each cell still has its own border rectangle around its content.
  4. 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 separate

border-spacing is ignored when borders are collapsed. Switch to separate first if you want gaps.

empty

empty-cells is separate-only

empty-cells controls whether empty cells show borders in the separate model. It does not apply when borders are collapsed.

styles

inset / outset change when collapsed

Per 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.

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.

99% Global support
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.

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

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.
The initial value is separate. Each cell keeps its own border, and you can space cells with border-spacing.
Use collapse for clean data tables where shared edges should look like a single grid line. Use separate when you want gaps between cells.
No. It applies only to table and inline-table elements. Ordinary block boxes do not use the table border models.
No. border-spacing only has an effect when border-collapse is separate. With collapse, spacing is ignored.
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.

Next: border-color

Learn how to set border color on one side or all four.

border-color tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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