CSS Reference ยท Lists, Tables and Generated Content
The empty-cells property
Reference for the CSS empty-cells property: show or hide borders and backgrounds of empty table cells, with a live example, rules, usage notes and support.
The empty-cells property controls whether a table cell that has no content still draws its borders and background. With the default value, show, an empty cell looks like any other cell. With hide, an empty cell becomes invisible: no border and no background are painted.
The property only has an effect when cells have their own borders, that is, when border-collapse is separate (the default). In a collapsed table the borders belong to the grid, so empty-cells is ignored.
table { border-collapse: separate; empty-cells: hide; }
Try it
Syntax
empty-cells: show | hide;
- Initial value:
show - Applies to: table cells
- Inherited: yes
- Animatable: no
- Computed value: as specified
Values
| Value | Description |
|---|---|
show |
Borders and background of empty cells are drawn. This is the default. |
hide |
Borders and background of empty cells are not drawn. |
Usage notes
- A cell counts as empty when it has no content at all, or only whitespace and collapsed white space. A cell holding
is not empty, because the non-breaking space is real content. - If every cell in a row is empty and
hideis set, the row looks as if it has been removed, but it still takes part in the table structure. - Because the property is inherited, set it on the
tableand every cell gets it. - With
border-collapse: collapsethe property does nothing. Switch toseparate(and useborder-spacingfor the gaps) if you need it. - For accessibility, an empty cell in a data table is often better replaced with a dash or the word "none", so that people using a screen reader know the value is deliberately blank.
Browser support
Supported in every current browser.
Related
border-collapseโ decides whether cell borders are mergedborder-spacingโ spacing between separated cellscaption-sideโ places the table caption- Lesson: Styling Tables