CSS Property Value How to - border-collapse: collapse;








Question

We would like to know how to border-collapse: collapse;.

Answer


<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of setting table border</title>
<style type="text/css">
table {<!--   w  ww  .  j  ava2s  .co  m-->
  width: 300px;
  border-collapse: collapse;
}

table, th, td {
  text-align: left;
  border: 1px solid #000000;
}
</style>
</head>
<body>
  <table>
    <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: