HTML Element Style How to - Set table height in percentage








Question

We would like to know how to set table height in percentage.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.abc {<!--from   w ww.j  av  a 2 s .  com-->
  height: 450px;
  background-color: #ccc
}

.abc div {
  height: 15%;
  background-color: #000
}

.abc table {
  height: 95%;
  background-color: red;
  width: 100%
}
</style>
</head>
<body>
  <div class="abc">
    <div>&sssssnbsp;</div>
    <table>
      <tr>
        <td>cv</td>
      </tr>
    </table>
  </div>
</body>
</html>

The code above is rendered as follows: