HTML | DOM Style borderCollapse Property

The DOM Style borderCollapse property in HTML is used to set or returns the border of table collapsed into a single border or not.

Syntax:

  • It is used to return the borderCollapse property.
    object.style.borderCollapse 
  • It is used to set borderCollapse property.
    object.style.borderCollapse = "separate|collapse|initial|inherit" 

Return Value: It returns a string value which represent a border of the table.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>
            DOM Style borderCollapse Property
        </title>
    </head>
      
    <body>
        <center>
            <h1>GeeksforGeeks</h1>
            <h2>DOM Style borderCollapse Property</h2>
              
            <table id = "gfg" border = "1">
            <tr>
                <th>Student Name</th>
                <th>Age</th>
            </tr>
            <tr>
                <td>Manas Chhabra</td>
                <td>19</td>
            </tr>
            <tr>
                <td>Hritik Bhatnagar</td>
                <td>20</td>
            </tr>
            </table>
            <br>
              
            <button type = "button" onclick = "geeks()">
                Submit
            </button>
              
            <!-- script to collapse border -->
            <script>
                function geeks() {
                    document.getElementById("gfg").style.borderCollapse
                                                        = "collapse";
                }
            </script>
        </center>
    </body>
</html>                    

chevron_right


Output:



Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>
            DOM Style borderCollapse Property
        </title>
    </head>
      
    <body>
        <center>
            <h1>GeeksforGeeks</h1>
            <h2>DOM Style borderCollapse Property</h2>
              
            <table id = "gfg" border = "1" 
                style = "border-collapse:collapse;">
              
                <tr>
                    <th>Student Nmae </th>
                    <th>Age</th>
                </tr>
                <tr>
                    <td>Manas Chhabra</td>
                    <td>19</td>
                </tr>
                <tr>
                    <td>Hritik Bhatnagar</td>
                    <td>20</td>
                </tr>
            </table>
            <br>
              
            <button type = "button" onclick = "geeks()">
                Submit
            </button>
              
            <!-- script to return borderCollapse value -->
            <script>
                function geeks() {
                alert(document.getElementById("gfg").style.borderCollapse);
                }
            </script>
        </center>
    </body>
</html>                    

chevron_right


Output:

Supported Browsers: The browser supported by DOM Style borderCollapse property are listed below:

  • Apple Safari 1.0
  • Google Chrome 1.2
  • Firefox 1.0
  • Opera 4.0
  • Internet Explorer 4.0


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.