empty-cells - HTML CSS CSS Property

HTML CSS examples for CSS Property:empty-cells

Description

The empty-cells CSS property shows or hides borders and backgrounds of table cells with no visible content.

A non-breaking space   is a visible content.

The following table summarizes the empty-cells Property.

Item Value
Default value: show
Applies to:The table-cell elements
Inherited: Yes
Animatable: No.

Syntax

The syntax of the property is as follows:


empty-cells:      show | hide | initial | inherit

Property Values

The following table describes the values of this property.

Value Description
showBorders and backgrounds are drawn for empty cells like normal cells. This is default value.
hideNo borders or backgrounds are drawn for empty cells.
initial Sets this property to its default value.
inherit take the value of its parent element empty-cells property.

The example below shows the empty-cells property.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Example of CSS empty-cells property</title>
  <style type="text/css">
    table {<!--  ww w  .ja v a2s.  co  m-->
        width: 300px;
        border-collapse: separate;
    }
    table, th, td{
        border: 1px solid #000000;
    }
    table.empty-show {
        empty-cells: show;
    }
    table.empty-hide {
        empty-cells: hide;
    }
</style>
 </head>
 <body>
  <h2>Table with Empty-cells</h2>
  <table class="empty-show">
   <tbody>
    <tr>
     <th>Name</th>
     <td>Tom</td>
    </tr>
    <tr>
     <th>Email</th>
     <td></td>
    </tr>
   </tbody>
  </table>
  <br>
  <h2>Table with Hidden Empty-cells</h2>
  <table class="empty-hide">
   <tbody>
    <tr>
     <th>Name</th>
     <td>Mary</td>
    </tr>
    <tr>
     <th>Email</th>
     <td></td>
    </tr>
   </tbody>
  </table>
 </body>
</html>

Related Tutorials