The empty-cells property lets you control whether empty table cells show their borders and background. It is a small but useful tool for cleaner HTML table layouts when some cells have no data.
01
Empty cells
Show or hide them.
02
Syntax
show and hide.
03
Default show
Borders stay visible.
04
Table only
Works on table cells.
05
border-collapse
Needs separate mode.
06
Cleaner grids
Sparse data tables.
Fundamentals
Introduction
The empty-cells property in CSS is used to control the rendering of table cells that do not contain any content. This property can be particularly useful when you want to ensure that empty cells are either shown or hidden, maintaining the visual consistency of your table layouts.
Definition and Usage
Apply empty-cells to a table element (or a cell, though setting it on the table is most common). When set to hide, cells with no content lose their visible borders and background, which can make sparse tables look cleaner while keeping the same HTML structure.
💡
Beginner Tip
empty-cells only works when the table uses border-collapse: separate. If your table uses border-collapse: collapse, this property will not change how empty cells look.
Foundation
📝 Syntax
The syntax for the empty-cells property is simple and can be applied to table elements.
syntax.css
element{empty-cells:value;}
Basic Example
empty-cells-hide.css
table{border-collapse:separate;empty-cells:hide;}
empty-cells: show;empty-cells: hide;
Default Value
The default value of the empty-cells property is show, meaning that empty cells are displayed with their borders and background.
Syntax Rules
Apply it to table elements or individual td / th cells.
Requires border-collapse: separate on the table to take effect.
A cell is empty only when it has no content — whitespace alone does not count as empty.
The property is inherited by table cells from the table element.
Hidden empty cells still occupy space in the table grid; only their borders and background disappear.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
show
Applies to
Table cell elements (td, th)
Inherited
Yes
Animatable
No
Required companion
border-collapse: separate
Reference
💎 Property Values
The empty-cells property accepts two keyword values:
Value
Description
show
This value ensures that empty cells are displayed with their borders and background.
hide
This value hides the borders and background of empty cells, making them invisible.
Context
When to Use show vs hide
Scenario
Recommended value
Data tables where every cell should look uniform
show (default)
Sparse grids, calendars, or timetables with gaps
hide
Tables using border-collapse: collapse
Neither value has effect — change collapse mode first
Cells with only or spaces
Not empty — hide will not apply
Preview
👀 Live Preview
Compare empty-cells: show and empty-cells: hide on the same table pattern:
empty-cells: show
1
3
5
empty-cells: hide
1
3
5
Hands-On
Examples Gallery
In this example, we’ll demonstrate the effect of the empty-cells property on a table with some empty cells — plus a schedule layout, border-collapse setup, and a styled data table.
📋 Basic Empty Cell Control
Start with the reference example — two tables with the same data but different empty-cells values.
Example 1 — Show vs Hide Comparison
See how show keeps empty cell borders visible while hide removes them.
Rounded, spaced cells with hidden empty slots create a dashboard-style grid without removing td elements from the markup.
A11y
♿ Accessibility
Hidden cells are still in the DOM — screen readers may still encounter empty td elements; use proper table headers and captions.
Use th for column and row labels so data relationships stay clear even when some cells are visually hidden.
Do not hide meaningful empty states if “no data” is important information for users.
Prefer semantic tables for tabular data rather than layout-only grids built with tables.
Consider aria-label on complex tables when visual empty-cell hiding might confuse the structure.
🧠 How empty-cells Works
1
Browser builds the table grid
Rows and columns are laid out from your table, tr, and td markup.
Structure
2
Empty cells are detected
Cells with no content qualify for empty-cells when border-collapse: separate is active.
Detection
3
show or hide is applied
show draws borders and background. hide removes them while the cell keeps its grid position.
Rendering
=
📋
Cleaner table presentation
Sparse tables look less cluttered without changing the underlying HTML grid.
Compatibility
🖥 Browser Compatibility
The empty-cells property is supported in all modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. It is also supported in older versions of Internet Explorer. However, it is always a good practice to test your website across different browsers to ensure compatibility.
✓ Baseline · Universal support
empty-cells everywhere
empty-cells has excellent cross-browser support. Both show and hide work in all modern browsers and legacy Internet Explorer.
99%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
empty-cells property99% supported
Bottom line:empty-cells is safe to use in all browsers. Remember to set border-collapse: separate for the property to take effect.
Wrap Up
🎉 Conclusion
The empty-cells property is a useful tool for web developers looking to control the display of empty table cells. By choosing whether to show or hide these cells, you can maintain the desired visual structure of your tables.
Experiment with this property to see how it can enhance the presentation of your tabular data. For beginners, remember the two key values — show (default) and hide — and always pair hide with border-collapse: separate.
Set border-collapse: separate when using empty-cells: hide
Use hide for sparse grids like calendars and timetables
Keep table headers (th) for accessible data tables
Test with real empty cells, not cells containing spaces
Combine with border-spacing for spaced card-style tables
❌ Don’t
Expect hide to work with border-collapse: collapse
Put in cells you want treated as empty
Use tables for page layout when CSS Grid or Flexbox is clearer
Hide empty cells if “no value” is meaningful data for users
Forget that hidden cells still take up grid space
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about empty-cells
Use these points when styling HTML tables.
5
Core concepts
📋01
Table cells
Controls empty ones.
Purpose
👁02
show
Default visible.
Default
🚫03
hide
No border or bg.
Common
⚙04
separate
Required mode.
Setup
📅05
Sparse grids
Schedules, calendars.
Use case
❓ Frequently Asked Questions
The empty-cells property controls whether empty table cells display their borders and background. With show, empty cells remain visible. With hide, they become invisible while still occupying their grid space in the table.
The initial value is show, meaning empty cells are displayed with their borders and background by default.
empty-cells only takes effect when border-collapse is set to separate on the table. If border-collapse is collapse, the property has no visible effect.
A cell is empty when it has no content at all. A cell that contains only whitespace, a non-breaking space, or an image is not considered empty.
Use empty-cells when your table structure needs placeholder cells for alignment, such as schedules or grids. If cells are not needed structurally, removing them from the HTML is often cleaner.