The border-collapse property controls how table cell borders interact. It helps you choose between merged borders and spaced, separate borders.
01
Table Borders
Cell border behavior.
02
collapse
Merge shared borders.
03
separate
Keep borders apart.
04
separate Default
Browser default mode.
05
On <table>
Apply to table element.
06
border-spacing
Works with separate.
Fundamentals
Definition and Usage
The border-collapse CSS property is used to control the spacing and border styling of table elements. It determines how the borders of adjacent table cells are combined or kept separate.
This property can help create cleaner and more compact table layouts by specifying how adjacent borders should interact. Most data tables on the web use collapse for a tidy grid look.
💡
Beginner Tip
Apply border-collapse on the <table> element, then style cell borders on th and td. Without cell borders, the collapse mode may not look very different at first glance.
Foundation
📝 Syntax
The syntax for border-collapse is simple. It is applied to the <table> element and accepts two keyword values.
With collapse, adjacent cell borders merge into one shared line.
With separate, each cell keeps its own border box.
border-spacing only works when the value is separate.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
separate
Applies to
table and inline-table elements
Inherited
Yes
Animatable
No
Common use
HTML data tables, pricing grids, comparison charts
Defaults
Default Value
The default value of border-collapse is separate. This means the borders of table cells are rendered as distinct and separate from each other unless you change the property.
Reference
💎 Property Values
The border-collapse property accepts two keyword values.
Value
Description
collapse
Adjacent cell borders are merged into a single border for a cleaner grid
separate
Each cell keeps its own border; gaps can be added with border-spacing
initial
Sets the property to its default value
inherit
Inherits the property value from its parent element
collapse
A
B
C
D
separate + spacing
A
B
C
D
Scope
Table Elements Only
border-collapse only affects real table layout. It does not change how borders behave on regular div grids or flex layouts.
Works on <table>
H1
H2
1
2
Not for div grids
A
B
C
D
Compare
collapse vs separate
Value
Border behavior
Best for
collapse
Shared borders become one line; no double-thick seams
Standard data tables, admin panels, and spreadsheet-style layouts
separate
Each cell border stays independent; spacing is possible
Card-like tables, spaced grids, and designs that need visible gaps
border-spacing
Only applies when collapse is separate
Adding space between cells without changing border width
Preview
👀 Live Preview
A table with collapsed borders:
Header 1
Header 2
Data 1
Data 2
Data 3
Data 4
Uses border-collapse: collapse; with 1px solid borders on th and td.
Hands-On
Examples Gallery
Try border-collapse with collapsed borders, separate borders, spacing, and a styled data table.
📚 Basic Table Border Modes
Compare the two core values of border-collapse on a simple HTML table.
Example 1 — Collapsed Borders
Merge adjacent cell borders into a single shared line for a clean grid.
Collapsed borders keep the grid lines clean while row styling adds readability. This pattern works well for dashboards and report tables.
🧠 How border-collapse Works
1
You style the table
Set border-collapse on the <table> element.
Table rule
2
You add cell borders
Apply borders to th and td so the grid is visible.
Cell styling
3
The browser merges or separates
With collapse, shared borders become one line. With separate, each cell keeps its own border.
Border model
=
▦
Clean table layout
Your table gets the border behavior you chose for readable rows and columns.
Compatibility
Universal Browser Support
The border-collapse property is widely supported across all major browsers, including Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer. It is a reliable choice for HTML table styling.
✓ Baseline · All browsers
Consistent table borders on every platform
Chrome, Firefox, Safari, Edge, and Opera all support border-collapse consistently.
100%Universal support
Google Chrome69+ · Desktop & Mobile
Full support
Mozilla Firefox66+ · Desktop & Mobile
Full support
Apple Safari12.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera56+ · Modern versions
Full support
border-collapse property100% supported
Bottom line: Use border-collapse freely in any project with HTML tables. It works consistently across all browsers.
Wrap Up
Conclusion
The border-collapse property is essential for managing the visual presentation of table borders. By choosing between collapse and separate, you control whether borders are merged or kept distinct.
Experiment with both values to achieve the layout that best suits your needs. For most data tables, collapse gives the cleanest result, while separate pairs well with border-spacing for spaced designs.
Use collapse for standard data tables and admin dashboards
Apply the property on the <table> element, not individual cells
Style borders on th and td for a visible grid
Use separate with border-spacing when you want gaps between cells
Test table rendering in multiple browsers for complex border colors
❌ Don’t
Expect border-collapse to work on non-table layouts
Use border-spacing when the table is set to collapse
Forget cell borders and wonder why the table looks unchanged
Assume separate always looks cleaner without adjusting spacing
Mix table borders with border-radius on cells without testing carefully
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about border-collapse
Use these points when styling HTML table borders.
5
Core concepts
▦01
Table Borders
Controls cell borders.
Purpose
⚙️02
separate Default
Cells stay apart.
Default
📝03
collapse
Merges shared lines.
Values
📏04
border-spacing
Works with separate.
Related
🔄05
On <table>
Not for div grids.
Scope
❓ Frequently Asked Questions
The border-collapse property controls whether adjacent table cell borders are merged into one border or kept separate. It is applied on the table element.
The initial value is separate. Each cell keeps its own distinct border by default.
Use collapse for clean data tables where shared borders should look like one line. Use separate when you want visible gaps between cells with border-spacing.
No. border-collapse only applies to table and inline-table elements. Regular block elements use normal border box behavior.
border-spacing only has an effect when border-collapse is separate. When you set collapse, border-spacing is ignored.