Page Widget How to - Auto grow table cell








Question

We would like to know how to auto grow table cell.

Answer


<html>
<head>
<style>
table {<!--  w  w w .j a va2 s. c  o m-->
  width: 75px;
}

table.one {
  table-layout: auto
}

table.two {
  table-layout: fixed;
}

td {
  padding: 5px;
  border-style: solid;
  border-width: 1px;
  border-color: #999999;
}
</style>
</head>
<body>
  <table class="one">
    <tr>
      <td>ABCDEFGHIJKLMNOPQRSTUVW XYZ asdf asdf asdf adsf asdf asdf
        asdf asdf asdf</td>
    </tr>
  </table>

  <table class="two">
    <tr>
      <td>ABCDEFGHIJKLMNOPQRSTUVW XYZ</td>
    </tr>
  </table>

</body>
</html>

The code above is rendered as follows: