Page Widget How to - Add padding to table cells








Question

We would like to know how to add padding to table cells.

Answer


<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of setting padding of table cells</title>
<style type="text/css">
table {<!--  w  w  w  .  jav a2 s.c  o m-->
  text-align: left;
}

table th {
  padding: 10px;
}

table td {
  padding: 50px;
}
</style>
</head>
<body>
  <table border="1">
    <caption>User Info</caption>
    <tr>
      <th>Name</th>
      <th>Email</th>
    </tr>
    <tr>
      <td>John</td>
      <td>john@mail.com</td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: