border-collapse

Merges adjacent table cell borders into a single line or keeps them separate.

Initial value
separate
Inherited
Yes
Animatable
no
Applies to
tables (display: table)
JavaScript
element.style.borderCollapse = "collapse"
On this page

Example

#
CSS
table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  border-bottom: 1px solid #333;
  padding: 8px 12px;
  text-align: left;
}
Preview

Definition and usage

#

By default (separate) every table cell has its own border, so double lines with a gap are visible between cells. The collapse value merges adjacent borders into one line.

In practice, border-collapse: collapse is the first line you add to the styles of a data table. The table then looks clean and tidy.

With separate, you set the gap between cells with the border-spacing property, and with collapse that property has no effect.

Syntax

#
Syntax
border-collapse: separate | collapse;

Values

#

Values in practice

#

separate

Double lines with gaps between cells.
.demo { border-collapse: separate; }

collapse

Single, shared lines.
.demo { border-collapse: collapse; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Start data tables with border-collapse: collapse and lines only under the rows. They look lighter than a full grid.
  • With collapse, border-radius on the table doesnโ€™t work. Wrap the table in an element with overflow: hidden.

Related entries

#

Spotted a mistake or missing an example? Write to us.