HTML Element Style How to - Place html table inside div








Question

We would like to know how to place html table inside div.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!-- ww w.j a  v  a 2 s .co m-->
<body>
  <div style="width: 920px; background: #c0c0c0; height: 500px;">
    <table style="width: 100%; background: red;" border="1">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
            <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>      
    </table>
  </div>
</body>
</html>

The code above is rendered as follows: