In this section, we will learn what the border-collapse is and how to use it in CSS.
CSS border-collapse Property Definition and Usage
By default, there’s a little space between each table cell, but CSS provided a property called `border-collapse` by which we can collapse (remove) these empty spaces.
Note: you can apply this property on <table> element.
CSS border-collapse Property Syntax
CSS border-collapse Property Value
There are two values that can be set for this property:
- separate: this is the default value that puts a little space between table cells.
- collapse: if we set this value, any space between table cells will be removed.
Example: border-collapse property in CSS
How Does CSS border-collapse Property Work?
The border-collapse property is used to remove any space between a table’s cells. This means even if we use `border-spacing` to set a space between a table’s cells, it will have no effect if there’s the `border-collapse` property with the value collapse used in that table.
Example: collapse table border
As you can see, using the `border-spacing` property has no effect if there’s the `border-collapse` property with the value “collapse” set for that table.