The border-collapse property is for use on <table> elements (or elements made to behave like a table through display: table or display: inline-table).
Syntax
border-collapse: collapse | separate;- Initial value: separate
- Applies to: table and inline-table elements
- Inherited: yes
- Computed value: as specified
- Animation type: discrete
Values
/* 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;- separate (default) – in which all table cells have their own independent borders and there may be space between those cells as well.
- /* 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;0 – in which both the space and the borders between table cells collapse so there is only one border and no space between cells.
When border-collapse is /* 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;0, it is notable that properties like /* 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;3 and /* 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;4 (on actual borders) don’t do anything. You’ll need /* 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;5 if you need either of those things.
CSS border-style property sets the style of all four sides of an element’s borders. It is a shorthand property for defining the border-top-style, border-bottom-style, border-left-style, border-right-style.
This property takes from one to four values. So each side can have its own value.
The default value of border-style is none. Borders are put on top of the element’s background.
You also need to know that some browsers do not support some styles. Usually, when a style is not supported, the browser draws the border as a solid one.
The border-style property is defined using one, two, three, or four values. When one value is defined, it applies the same style to all four sides. When two values are defined, the first style applies to the top and bottom sides, the second to the left and right sides. When three values are specified, the first style applies to the top, the second to the left and right, the third to the bottom side. When four values are specified, the styles apply to the top, right, bottom, and left, like a clockwise order.
In this chapter you will learn:
Description
border-collapse property controls if to merge two borders, collapse to one border.
Syntax and Property Values
border-collapse: collapse | separate | inherit
The property values are listed in the following table.
Example
value | value |
value |
Click to view the demo
Next chapter...
What you will learn in the next chapter:
The border-collapse property sets whether table borders should collapse into a single border or be separated as in standard HTML.
Show demo ❯
Default value:separateInherited:yesAnimatable:no. Read about animatableVersion:CSS2JavaScript syntax:object.style.borderCollapse="collapse" Try it
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Propertyborder-collapse1.05.01.01.24.0
CSS Syntax
border-collapse: separate|collapse|initial|inherit;
Property Values
ValueDescriptionDemoseparateBorders are separated; each cell will display its own borders. This is default.Demo ❯collapseBorders are collapsed into a single border when possible (border-spacing and empty-cells properties have no effect)Demo ❯initialSets this property to its default value. Read about initialinheritInherits this property from its parent element. Read about inherit
More Examples
Example
When using "border-collapse: separate", the border-spacing property can be used to set the space between the cells: