HTML Element Style How to - Stretch a div vertically in a td








Question

We would like to know how to stretch a div vertically in a td.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!-- ww  w .  j  ava2s .  c  o m-->
  height: 100%;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td style='height: 200px; border: 1px solid red;'>
        <div style="border: 1px solid blue;">hello</div>
      </td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: