CSS empty-cells Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

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.

CSS Syntax

syntax.css
empty-cells: show | hide | initial | inherit;

Usually set on the table. Cells inherit the value unless a cell overrides it.

Property Values

ValueDescriptionTry it
showDraw borders and backgrounds on empty cells (initial value)Try it
hideDo not draw borders or backgrounds on empty cellsTry it
initialResets to showTry it
inheritTakes the parent element's valueTry it

How to Use empty-cells

Use it when a table needs placeholder cells but you want empty ones less visible.

  1. Build a real HTML <table> with borders on cells.
  2. Keep border-collapse: separate (the default in many cases, but set it explicitly if unsure).
  3. Set empty-cells: show or hide on the table.
  4. Leave truly empty <td></td> cells — content or &nbsp; counts as not empty.
PieceRequired?Role
Table cellsYesProperty applies to table-cell elements
border-collapse: separateYes (to see it)No visible effect when borders are collapsed
Cell borders / backgroundYes (to see it)What show / hide toggles on empty cells
InheritedBy designSet on table for all cells, or override one cell

Live Preview

Toggle empty-cells. Empty name and age cells change whether their borders stay visible.

Table uses border-collapse: separate. Empty cells have no text inside.

Table
NameAge
25
Louise Q.
Stan L.71

empty-cells: show

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).

CSS
<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>
Try It Yourself

How It Works

  1. Separate borders. border-collapse: separate allows empty-cells to apply.
  2. Set show. Empty cells still get borders and backgrounds.
  3. Leave the cell empty. <td></td> has no visible content.
  4. Compare with hide in the next example or the live preview.

Example 2 — Hide Empty Cells

Skip drawing borders on empty cells.

CSS
<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>
Try It Yourself

How It Works

  1. Set hide. Empty cells do not draw borders or backgrounds.
  2. Filled cells stay normal. Cell A still shows its border.
  3. Space remains. The empty cell still occupies its place in the grid.
  4. 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.

CSS
<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>
Try It Yourself

How It Works

  1. Use separate borders. MDN: empty-cells only affects tables with border-collapse: separate.
  2. Optional spacing. border-spacing is easier to see with separate borders.
  3. Then set hide or show. Without separate mode, changing the value looks like nothing happened.
  4. If it “does nothing,” check for border-collapse: collapse first.

Edge Cases & Pitfalls

If empty cells still show borders, check these first.

collapse

Requires border-collapse: separate

With border-collapse: collapse, empty-cells has no visible effect. Switch to separate.

content

Whitespace and &nbsp; are not “empty”

A cell with text, an image, or &nbsp; is treated as having content. Use a truly empty <td></td>.

space

hide does not remove the cell

The cell still occupies its grid slot. Only borders and backgrounds on empty cells are skipped.

scope

Only for table cells

It does not apply to flex, grid, or div “fake tables.” Use a real <table> with cell display types.

a11y

Keep 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.

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.

99% Browser support
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 support
empty-cells Widely supported

Bottom line: Safe for table styling. Pair with separate borders. It is not a runtime API.

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 &nbsp; 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.

Next: filter

Apply visual effects like blur and brightness.

filter tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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