CSS empty-cells Property

You are Here:

CSS empty-cells Property

CSS empty-cells property sets whether borders and backgrounds appear around <table> cells that have no visible content.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> table, td, th{ border: 1px solid black; } table{ width: 200px; } #point{ empty-cells: show; } #point1{ empty-cells: hide; } </style> </head> <body> <h1>CSS empty-cells Property</h1> <h2>empty-cells: show;</h2> <table id="point"> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Jos</td> <td>28</td> </tr> <tr> <td>Alex</td> <td></td> </tr> </table> <h2>empty-cells: hide;</h2> <table id="point1"> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Jos</td> <td>28</td> </tr> <tr> <td>Alex</td> <td></td> </tr> </table> </body> </html>

Syntax

Using CSS

element{ empty-cells: hide; }

Using Javascript

object.style.emptyCells="hide";

Animatable

No, empty-cells property is not animatable. CSS Animatable Properties Reference.

Default Value

Default value for CSS empty-cells property is show.

Property Value

The following table provides a list of values for CSS empty-cells property.

ValueExplanation
showDisplay borders on empty cells.
hideHide borders on empty cells.

Using JavaScript

In the following example, we will demonstrate how to change the CSS empty-cells property of an element using JavaScript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> table, td, th{ border: 1px solid black; } table{ width: 200px; } </style> </head> <body> <h1>CSS empty-cells Property</h1> <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Jos</td> <td>28</td> </tr> <tr> <td>Alex</td> <td></td> </tr> </table> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("table")[0]; function myFunction(){ x.style.emptyCells = "hide"; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author