border-collapse
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The When cells are collapsed, the When cells are separated, the distance between cells is defined by the The border-collapse
CSS property sets whether cells inside a have shared or separate borders.
Try it
border-collapse: collapse;
border-collapse: separate;
Cell 1.1
Cell 1.2
Cell 2.1
Cell 2.2
Cell 3.1
Cell 3.2
table {
width: 15rem;
table-layout: fixed;
}
td {
border: 5px solid;
border-color: crimson dodgerblue orange limegreen;
padding: 0.75rem;
}
border-style
value of inset
behaves like ridge
, and outset
behaves like groove
.border-spacing
property.Syntax
/* Keyword values */
border-collapse: collapse;
border-collapse: separate;
/* Global values */
border-collapse: inherit;
border-collapse: initial;
border-collapse: revert;
border-collapse: revert-layer;
border-collapse: unset;
border-collapse
property is specified as a single keyword, which may be chosen from the list below.Values
Formal definition
Initial value separate
Applies to table
and inline-table
elementsInherited yes Computed value as specified Animation type discrete Formal syntax
border-collapse =
separate |
collapse Examples
A colorful table of browser engines
HTML
border-collapse: separate
Browser
Layout Engine
Firefox
Gecko
Edge
EdgeHTML
Safari
WebKit
Chrome
Blink
Opera
Blink
border-collapse: collapse
Browser
Layout Engine
Firefox
Gecko
Edge
EdgeHTML
Safari
WebKit
Chrome
Blink
Opera
Blink
CSS
.collapse {
border-collapse: collapse;
}
.separate {
border-collapse: separate;
}
table {
display: inline-table;
margin: 1em;
border: dashed 5px;
}
table th,
table td {
border: solid 3px;
}
.fx {
border-color: orange blue;
}
.gk {
border-color: black red;
}
.ed {
border-color: blue gold;
}
.tr {
border-color: aqua;
}
.sa {
border-color: silver blue;
}
.wk {
border-color: gold blue;
}
.ch {
border-color: red yellow green blue;
}
.bk {
border-color: navy blue teal aqua;
}
.op {
border-color: red;
}
Result
Specifications
Specification Cascading Style Sheets Level 2
# propdef-border-collapseBrowser compatibility
See also
border-spacing
, border-style
border-collapse
property alters the appearance of the HTML element.