Set the space between cells in a table - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderSpacing

Description

Set the space between cells in a table

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<table id="myTable" border="1" style="border-spacing:10px;">
  <tr>
    <th>Month</th>
    <th>Dollor</th>
  </tr>//from w w w . j a  v  a2 s . c  o m
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$150</td>
  </tr>
</table>
<br>

<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {
    document.getElementById("myTable").style.borderSpacing = '5px 5px';
}
</script>

</body>
</html>

Related Tutorials