HTML Element Style How to - Hide empty table cell








Question

We would like to know how to hide empty table cell.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
table {<!--from ww w .j  a v a2  s  . co m-->
  
}

table td {
  empty-cells: hide;
  border: 3px double;
  padding: 3px;
}
</style>
</head>
<body>
  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>1</td>
      <td>2</td>
    </tr>
    <tr>
      <td>3</td>
      <td></td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: