HTML Element Style How to - Stretch Table's Width to fit web browser








Question

We would like to know how to stretch Table's Width to fit web browser.

Answer


<html>
<head>
<style type="text/css">
* {<!-- ww  w .j  a  va2  s. com-->
  margin: 0px;
  padding: 0px;
}

html, body {
  height: 100%;
}
</style>
</head>
<body>
  <table style="width: 100%; height: 100%; background-color: #EEE;">
    <tr><td>java2s.com</td></tr>
  </table>
</body>
</html>

The code above is rendered as follows: