CSS

CSS

Master CSS border-collapse: How to Design Clean and Modern Tables

By default, HTML tables can look a bit outdated, featuring awkward spaces between cells and double-bordered lines. If you want your data tables to look sleek, sharp, and professional, you need to master the CSS border-collapse property.

In this quick guide, you will learn how to instantly transform messy tables into modern, beautifully organized data layouts.

🎯 What is overflow-collapse?

The border-collapse property determines whether the borders of an HTML <table> element and its cells (<td>, <th>) are separated or merged into a single, unified line.

Simply put: It controls whether your table cells have their own individual borders or share a single border with their neighbors.

🛠️ border-collapse Values and Practical Use Cases

This property has two primary values that completely change the visual structure of your tables:

1. separate (Default)

Every single cell retains its own distinct border, which often results in a "double border" look. When using this value, you can also use the border-spacing property to control the distance between cell borders.

Best Used For: Retro or card-style tables where you want cells to look like independent elements or blocks floating next to each other.

CSS

table {
  border-collapse: separate;
}
                

2. collapse (The Professional Standard)

Adjacent cell borders automatically merge into a single, clean line. The browser removes all spacing between cells, creating a compact and highly readable grid.

Best Used For: Modern pricing tables, analytics dashboards, and responsive data sheets. This is the ultimate industry standard for clean UI design.

CSS

table {
  border-collapse: collapse;
}
                

📊 Quick Comparison Table

Value Behavior Ideal Use Case
separate Cell borders stay detached; spacing is allowed. Retro layouts or isolated grid designs.
collapse Borders merge into single lines; no spacing. Modern, professional, and clean data tables.
initial Resets the property to its default value (separate). Resetting inheritance inside custom components.
inherit Adopts the border-collapse value of its parent. Maintaining consistency across nested tables.
  • 💡 Extra Tip: Playing with Spacing

  • If you stick with border-collapse: separate, you can use border-spacing: 10px; to push the cells apart. However, keep in mind that border-spacing will have absolutely no effect if your table is set to border-collapse: collapse.