HTML Element Style How to - Remove border-spacing before first item and after last item








Question

We would like to know how to remove border-spacing before first item and after last item.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
table {<!--   w  w w .  j  a v  a  2 s  . c  o  m-->
  width: 100%;
  border: 5px solid #222;
  border-collapse: separate;
}

td+td {
  margin-left: 8%;
}

td.last {
  float: right;
}

td {
  display: inline-block;
  width: 27%;
  height: 20px;
  border: 1px solid #999;
  background: #ccc;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td></td>
      <td></td>
      <td class="last"></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td class="last"></td>
    </tr>    
    <tr>
      <td></td>
      <td></td>
      <td class="last"></td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: