Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

empty-cells — borders and backgrounds of empty cells

The empty-cells property controls whether empty table cells have painted borders and backgrounds. It works in the separated-borders model, with border-collapse: separate; it has no effect with collapse.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

empty-cells: show | hide;

empty-cells controls the painting of empty cells' borders and backgrounds with border-collapse: separate. The initial value, show, retains these decorations, while hide suppresses their painting. With border-collapse: collapse, the property has no effect.

The property applies to table-cell boxes and is inherited. You can therefore set it on the table and override it for an individual cell. hide does not remove the element or its position in the table grid; it is not equivalent to display: none.

Emptiness depends on content participating in rendering: whitespace collapsed away by white-space does not fill a cell. In-flow content or a float, even an empty element, can make the cell nonempty. Do not judge emptiness solely by the absence of visible letters.

In the example, the middle cell inherits hide, while the last cell receives show through .show. The expected result is the gray table background showing at the middle cell's position, with yellow backgrounds and black borders on the other two cells.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>empty-cells</title>
<style>
  table {
    border-collapse: separate;
    border-spacing: 6px;
    background: #ddd;
    empty-cells: hide;
  }
  td {
    width: 80px;
    height: 40px;
    border: 2px solid #000;
    background: #ff0;
    text-align: center;
  }
  .show { empty-cells: show; }
</style>
<table aria-label="empty-cells comparison">
  <tr><td>A</td><td></td><td class="show"></td></tr>
</table>
</html>

Result

Expected visual result: one row with three cell positions. The first cell shows A with a black border and yellow background. The middle cell has no painted border or yellow background; the gray table background shows through. The last, empty cell has a black border and yellow background.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources