The border-spacing property controls the gap between table cell borders. It is the CSS way to add breathing room inside HTML tables when borders stay separate.
01
Cell Gaps
Space between borders.
02
1 or 2 Values
Horizontal and vertical.
03
0 Default
No extra gap.
04
On <table>
Table element only.
05
Needs separate
Works with separate.
06
px / em / rem
Length units.
Fundamentals
Definition and Usage
The border-spacing CSS property sets the distance between the borders of adjacent cells in a table. This gives you control over how much space appears between cells without changing the cell border width itself.
It is especially useful for card-like tables, comparison grids, and layouts where you want visible gaps between bordered cells. Pair it with cell borders on th and td for the best visual result.
💡
Beginner Tip
border-spacing only works when border-collapse is separate. If your table uses collapse, spacing is ignored — use padding or margins on cells instead for inner space.
Foundation
📝 Syntax
The syntax for border-spacing accepts one or two length values on the <table> element.
border-spacing: 6px; creates small gaps so rounded cell borders read as separate cards in a pricing-style grid.
🧠 How border-spacing Works
1
Keep borders separate
Use border-collapse: separate on the table so spacing can apply.
Table mode
2
Set spacing lengths
Choose one value for both axes or two values for horizontal and vertical gaps.
Length values
3
The browser adds gaps
Space appears between adjacent cell border boxes. Padding inside cells stays unchanged.
Cell gaps
=
⊞
Spaced table grid
Your table cells get visible gaps between borders for a cleaner, more open layout.
Compatibility
Universal Browser Support
The border-spacing property is supported in all major browsers, including Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer. It is a reliable choice for HTML table styling.
✓ Baseline · All browsers
Reliable table spacing on every platform
Chrome, Firefox, Safari, Edge, and Opera all support border-spacing 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-spacing property100% supported
Bottom line: Use border-spacing freely in any project. It works consistently across all browsers.
Wrap Up
Conclusion
The border-spacing property is a valuable tool for controlling gaps between table cell borders. Whether you want a tight grid or a card-like layout with visible space, adjusting spacing helps you match your design goals.
Experiment with single values like 8px or two-value pairs like 10px 15px to see how horizontal and vertical gaps change the table feel.
Use border-collapse: separate when you need spacing between cells
Style cell borders on th and td so gaps are visible
Use two values when horizontal and vertical gaps should differ
Combine moderate spacing with rounded corners for card-style tables
Test table layout in multiple browsers for consistent spacing
❌ Don’t
Expect spacing to work when border-collapse is collapse
Use border-spacing on non-table elements like div grids
Confuse spacing with cell padding — they control different areas
Use negative values — spacing lengths must be zero or positive
Rely on very large spacing on dense data tables meant for scanning
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about border-spacing
Use these points when adding gaps to HTML tables.
5
Core concepts
⊞01
Cell Gaps
Space between borders.
Purpose
⚙️02
0 Default
No extra gap.
Default
↔03
1 or 2 Values
Horizontal / vertical.
Syntax
📝04
Needs separate
Not for collapse.
Requirement
🔄05
Table Only
Not for div grids.
Scope
❓ Frequently Asked Questions
The border-spacing property sets the distance between the borders of adjacent table cells. It creates visible gaps in the table grid when borders are separate.
The initial value is 0, which means there is no extra space between adjacent cell borders.
border-spacing only applies when border-collapse is separate. If the table uses collapse, spacing is ignored.
Yes. Use two length values: the first controls horizontal spacing and the second controls vertical spacing. One value applies to both axes.
No. border-spacing only applies to table and inline-table elements. Use gap in Grid or Flexbox for non-table layouts.