I would like to know how to hide a row in HTML. Using the CSS method of style="empty-cells : hide;" seems to work, but if the <h4> tag is included in the empty table, then the row is not hidden.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
</head>
<body>
<form name="form_simple" action=" " method="get">
<table border="1px" style="empty-cells : hide;">
<tr><td><h4>Empty cells should not have any borders around them</h4></td></tr>
<tr><td></td></tr>
<tr><td><h4>Empty cells should not have any borders around them.</h4></td></tr>
<tr><td><h4>Empty cells should not have any borders around them.</h4></td></tr>
</table>
</form>
</body>
</html>
style="empty-cells : hide;" works for <tr><td></td></tr>, but not for <tr><td><h4></h4></td></tr>
Here’s a work-around:
jsfiddle
Change
*toh4if you only want to targeth4.Note that according to MDN,
empty-cellsshould apply to table-cell element, not table (although browsers seem to accept it anyway).