HTML Element Style How to - Make a table with equal column width








Question

We would like to know how to make a table with equal column width.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
table {<!-- w w  w  . java 2 s  .  c o  m-->
  width: 100%;
  border-collapse: collapse;
}

td {
  width: 50%;
  text-align: left;
  border: 1px solid black;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td>Word</td>
      <td>Definition</td>
    </tr>
    <tr>
      <td>Word</td>
      <td>Definition</td>
    </tr>
    <tr>
      <td>Word</td>
      <td>Definition</td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: