/

HTML / CSS / JavaScript Tutorial

CSS Property: empty-cells

[this page | pdf | back links]

The CSS (CSS2) empty-cells property indicates whether to display borders and background for empty cells in a table (only applicable if border-collapse property is "separate").

 

Valid property values (other than inherit and initial) are:

 

Value

Description

hide

No background or borders shown on empty cells

show

(default value). Background and borders shown on empty cells

 

Default Value:

show

JavaScript syntax:

e.g. object.style.emptyCells="hide"

Inherited:

Yes

Animatable:

No

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,tr {border: thin solid black; }
td.x1 {empty-cells: hide;}
</style>
</head>
<body>
1. Element with default property<br>
<table>
  <tr><td>1</td><td></td><td>2</td></tr>
  <tr><td>A</td><td>B</td><td></td></tr>
</table><br>
2. Element set using in-file HTML style<br>
<table>
  <tr><td>1</td><td class="x1"></td><td>2</td></tr>
  <tr><td>A</td><td>B</td><td></td></tr>
</table><br>
3. Element set using JavaScript<br>
<table>
  <tr><td>1</td><td id="x2"></td><td>2</td></tr>
  <tr><td>A</td><td>B</td><td></td></tr>
</table><br>

<script>
document.getElementById("x2").style.emptyCells = "hide";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyEmptyCells() {
  var x = document.createElement("DIV"); x.style.emptyCells = "hide"; return (window.getComputedStyle(x, null).emptyCells == "hide");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile