Search w3schools.com:

SHARE THIS PAGE

Style emptyCells Property

Style Object Reference Style Object

Definition and Usage

The emptyCells property sets or returns whether to show the border and background of empty cells, or not.

Syntax

Set the emptyCells property:

Object.style.emptyCells="show|hide|inherit"

Return the emptyCells property:

Object.style.emptyCells

Value Description
show Border and background are shown in empty cells
hide Border and background are hidden in empty cells
inherit The value of the emptyCells property is inherited from parent element


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The emptyCells property is supported in all major browsers.

Note: The default value is different in different browsers. In IE, Chrome and Safari, the default value is "show", while in Firefox and Opera the default value is "hide".

Note: The emptyCells property is not supported in IE7 and earlier. IE8 requires a !DOCTYPE. IE9 supports it.


Example

Example

Change how empty cells are shown:

<html>
<head>
<script>
function show()
{
document.getElementById("myTable").style.emptyCells="show";
}
function hide()
{
document.getElementById("myTable").style.emptyCells="hide";
}
</script>
</head>
<body>

<table id="myTable" border="1">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td></td>
  </tr>
</table>
<br>
<button type="button" onclick="show()">Show empty cells</button>
<button type="button" onclick="hide()">Hide empty cells</button>

</body>
</html>

Try it yourself »


Style Object Reference Style Object

W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The HTML5 Certificate documents your knowledge of advanced HTML5.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]