×

Save Your Code

If you click the save button, your code will be saved, and you get an URL you can share with others.

By clicking the "Save" button you agree to our terms and conditions.

Report Error

×

Save to Google Drive

If you have a Google account, you can save this code to your Google Drive.

Google will ask you to confirm Google Drive access.

×

Open from Google Drive

If you have saved a file to Google Drive, you can open it here:

Result Size: 625 x 571
x
 
<!DOCTYPE html>
<html>
<head>
<style> 
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>
<h1>Change border-collapse with JavaScript</h1>
<p>Click the "Try it" button to change the border-collapse property of the TABLE element:</p>
<button onclick="myFunction()">Try it</button>
<table id="myTABLE">
  <tr>
    <th>Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Emil</td>
    <td>9</td>
  </tr>
  <tr>
    <td>Tobias</td>
    <td>7</td>
  </tr>
  <tr>
    <td>Linus</td>
    <td>2</td>
  </tr>
</table>
<script>
function myFunction() {
  document.getElementById("myTABLE").style.borderCollapse = "collapse";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/cssref/tryit.asp?filename=trycss_js_border-collapse by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 05 Jun 2019 13:59:31 GMT -->
</html>
×

Report a Problem: