CSS border-collapse Property

You are Here:

CSS border-collapse Property

CSS border-collapse property sets whether cells inside a <table> have shared or separate borders.


HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> table, td, th{ border: 1px solid black; } #point{ border-collapse: separate; } #point1{ border-collapse: collapse; } </style> </head> <body> <h1>CSS border-collapse Property</h1> <h2>border-collapse: separate;</h2> <table id="point"> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Jos</td> <td>28</td> </tr> <tr> <td>Alex</td> <td>34</td> </tr> </table> <h2>border-collapse: collapse;</h2> <table id="point1"> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Jos</td> <td>28</td> </tr> <tr> <td>Alex</td> <td>34</td> </tr> </table> </body> </html>


Using CSS

element{ border-collapse: collapse; }

Using Javascript



No, border-collapse property is not animatable. CSS Animatable Properties Reference.

Default Value

Default value for CSS border-collapse property is separate.

Property Value

The following table provides a list of values for CSS border-collapse property.

separateSpecifies that adjacent cells have distinct borders.
collapseSpecifies that adjacent cells have shared borders.

Using JavaScript

In the following example, we will demonstrate how to change the CSS border-collapse property of an element using JavaScript.


HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> table, td, th{ border: 1px solid black; } </style> </head> <body> <h1>CSS border-collapse Property</h1> <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Jos</td> <td>28</td> </tr> <tr> <td>Alex</td> <td>34</td> </tr> </table> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("table")[0]; function myFunction(){ x.style.borderCollapse = "collapse"; } </script> </body> </html>


Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author