CSS empty-cells Property

Definition
Definition and Usage
The empty-cells property sets whether borders and backgrounds appear around <td> / <th> cells that have no visible content.
It applies to table-cell elements, is inherited, and only has an effect when border-collapse is separate.
Baseline · Widely available.Not deprecated. Supported across modern browsers. Remember: no effect with border-collapse: collapse.
Syntax
CSS Syntax
empty-cells: show | hide | initial | inherit;
Usually set on the table. Cells inherit the value unless a cell overrides it.
Values
Property Values
| Value | Description | Try it |
|---|
show | Draw borders and backgrounds on empty cells (initial value) | Try it |
hide | Do not draw borders or backgrounds on empty cells | Try it |
initial | Resets to show | Try it |
inherit | Takes the parent element's value | Try it |
Approach
How to Use empty-cells
Use it when a table needs placeholder cells but you want empty ones less visible.
- Build a real HTML
<table> with borders on cells. - Keep
border-collapse: separate (the default in many cases, but set it explicitly if unsure). - Set
empty-cells: show or hide on the table. - Leave truly empty
<td></td> cells — content or counts as not empty.
| Piece | Required? | Role |
|---|
| Table cells | Yes | Property applies to table-cell elements |
border-collapse: separate | Yes (to see it) | No visible effect when borders are collapsed |
| Cell borders / background | Yes (to see it) | What show / hide toggles on empty cells |
| Inherited | By design | Set on table for all cells, or override one cell |
Try it
Live Preview
Toggle empty-cells. Empty name and age cells change whether their borders stay visible.
Code
CSS Examples
Each snippet focuses on empty-cells. Use Try It Yourself for a live editor.
Example 1 — Show Empty Cells
Keep borders around empty cells (the default).
<style>
table {
border-collapse: separate;
empty-cells: show;
}
td {
border: 1px solid #333;
padding: 6px;
}
</style>
<table>
<tr><td>A</td><td></td></tr>
</table>
How It Works
- Separate borders.
border-collapse: separate allows empty-cells to apply. - Set
show. Empty cells still get borders and backgrounds. - Leave the cell empty.
<td></td> has no visible content. - Compare with hide in the next example or the live preview.
Example 2 — Hide Empty Cells
Skip drawing borders on empty cells.
<style>
table {
border-collapse: separate;
empty-cells: hide;
}
td {
border: 1px solid #333;
padding: 6px;
}
</style>
<table>
<tr><td>A</td><td></td></tr>
</table>
How It Works
- Set
hide. Empty cells do not draw borders or backgrounds. - Filled cells stay normal. Cell
A still shows its border. - Space remains. The empty cell still occupies its place in the grid.
- Not the same as removing the
td. Structure stays; only paint is skipped.
Example 3 — Needs Separate Borders
Set border-collapse: separate so the property can work.
<style>
table {
border-collapse: separate;
border-spacing: 4px;
empty-cells: hide;
}
td {
border: 1px solid #333;
padding: 6px;
}
</style>
<table>
<tr>
<td>Name</td>
<td></td>
</tr>
</table>
How It Works
- Use separate borders. MDN:
empty-cells only affects tables with border-collapse: separate. - Optional spacing.
border-spacing is easier to see with separate borders. - Then set hide or show. Without separate mode, changing the value looks like nothing happened.
- If it “does nothing,” check for
border-collapse: collapse first.
Edge Cases & Pitfalls
If empty cells still show borders, check these first.
contentWhitespace and are not “empty”
A cell with text, an image, or is treated as having content. Use a truly empty <td></td>.
spacehide does not remove the cell
The cell still occupies its grid slot. Only borders and backgrounds on empty cells are skipped.
scopeOnly for table cells
It does not apply to flex, grid, or div “fake tables.” Use a real <table> with cell display types.
a11yKeep table semantics
Do not change a data table’s display to flex/grid just to style gaps — that can break how assistive tech announces the table.
Compatibility
Browser Support
empty-cells is a browser CSS property for table cells. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
empty-cells
Supported in all modern browsers and older engines. Effect only appears with border-collapse: separate.
Google Chrome All modern versions
Full support
Mozilla Firefox All modern versions
Full support
Apple Safari All modern versions
Full support
Microsoft Edge All modern versions
Full support
Opera All modern versions
Full support
Samsung Internet Supported
Full support
Internet Explorer Supported
Full supportempty-cells Widely supported
Bottom line: Safe for table styling. Pair with separate borders. It is not a runtime API.
Remember
Key Takeaways
Role: show or hide borders/backgrounds on empty table cells.
Values: show (default) or hide. Inherited.
Requires border-collapse: separate.
Empty means no visible content — not or text.
One line: with separate table borders, empty-cells decides if empty cells still paint borders.
Frequently Asked Questions
It controls whether borders and backgrounds are drawn around table cells that have no visible content. Use show to draw them and hide to skip them.
The initial value is show. Empty cells still display their borders and backgrounds unless you set hide.
It only works when border-collapse is separate. With border-collapse: collapse, empty-cells does nothing visible.
A cell with no visible content. Text, images, or a non-breaking space usually count as content, so those cells are not empty.
Yes. You can set it on the table and cells inherit it, or override it on a specific cell.
It is Baseline Widely available. It is a browser CSS table property, not a Node.js runtime feature.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful