How to Use Border Collapse in CSS
Use border-collapse when you want table borders to merge into clean single lines instead of showing doubled edges between cells. This is one of the most important table cleanup properties in CSS.
What you’ll build or solve
You’ll learn how to use border-collapse in CSS to make table borders look cleaner. You’ll also know when collapsed borders improve readability the most.
Learn CSS on Mimo
When this approach works best
This approach is the right choice when your table borders look doubled, messy, or too visually heavy.
Common real-world scenarios include:
- Pricing comparison tables
- Analytics reports
- Grade sheets
- Product matrices
- Scheduling grids
This is a bad idea when the design intentionally uses separated cells with spacing between them.
Prerequisites
You only need:
- A basic HTML table with borders
- A text editor
- Basic HTML and CSS knowledge
Step-by-step instructions
Step 1: Apply border-collapse: collapse to the table
Start with a bordered table.
HTML
<table class="pricing">
<tr>
<th>Country</th>
<th>Price</th>
</tr>
<tr>
<td>USA</td>
<td>$29</td>
</tr>
</table>
<style>
.pricing,
.pricing th,
.pricing td {
border: 1px solid #ddd;
}
</style>
Then collapse the borders on the table itself.
HTML
<style>
.pricing {
border-collapse: collapse;
}
</style>
What to look for:
- Borders between cells become single lines
- The property belongs on the
<table>, not the cells - Cell borders still need their own
bordervalues - Collapsed borders improve readability for dense tables
- Use separated borders only when spacing between cells is intentional
Examples you can copy
Pricing table
HTML
<table class="plans">
<tr>
<th>Region</th>
<th>Price</th>
</tr>
<tr>
<td>UK</td>
<td>£25</td>
</tr>
</table>
<style>
.plans {
border-collapse: collapse;
}
</style>
Analytics table
HTML
<table class="metrics">
<tr>
<th>Country</th>
<th>CTR</th>
</tr>
<tr>
<td>France</td>
<td>4.2%</td>
</tr>
</table>
<style>
.metrics {
border-collapse: collapse;
}
</style>
Launch schedule
HTML
<table class="schedule">
<tr>
<th>Market</th>
<th>Date</th>
</tr>
<tr>
<td>USA</td>
<td>Monday</td>
</tr>
</table>
<style>
.schedule {
border-collapse: collapse;
}
</style>
Common mistakes and how to fix them
Mistake 1: Applying border-collapse to cells
What the reader might do:
HTML
td,
th {
border-collapse: collapse;
}
Why it breaks: the property only works on the table element.
Corrected approach:
HTML
table {
border-collapse: collapse;
}
Mistake 2: Forgetting actual borders
What the reader might do:
HTML
table {
border-collapse: collapse;
}
Why it breaks: without cell borders, there is nothing to collapse.
Corrected approach:
HTML
table,
th,
td {
border: 1px solid #ddd;
}
Mistake 3: Using collapse when cell spacing is required
What the reader might do:
HTML
table {
border-collapse: collapse;
}
Why it breaks: separated card-like cells lose their intentional spacing.
Corrected approach:
Skip collapse and use border-spacing if visible gaps between cells are part of the design.
Troubleshooting
If borders still look doubled, confirm border-collapse is applied to the table selector.
If nothing changes, add borders to th and td.
If the table loses intended spacing, switch to separated borders.
If the layout still feels heavy, use lighter border colors.
Quick recap
- Use
border-collapse: collapseon the table - Keep borders on cells
- Collapse removes doubled edges
- Use separated borders only for intentional spacing
- Great for readable dense tables
Join 35M+ people learning for free on Mimo
4.8 out of 5 across 1M+ reviews
Check us out on Apple AppStore, Google Play Store, and Trustpilot