Difference between CSS border-collapse:collapse; and border-collapse:separate;


The following image justifies the difference between collapse and separate. The separate value of the border-collapse property separates the borders of the cells:

Example

You can try to run the following code to understand the difference between border-collapse separate and collapse value:

<html>
   <head>
      <style>
         table.one {
            border-collapse:collapse;
         }
         table.two {
            border-collapse:separate;
         }
         td.a {
            border-style:dotted;
            border-width:2px;
            border-color:#000000;
            padding: 20px;
         }
         td.b {
            border-style:solid;
            border-width:2px;
            border-color:#333333;
            padding:20px;
         }
      </style>
   </head>
   <body>
      <table class = "one">
         <caption>Border Collapse</caption>
         <tr><td class = "a"> India</td></tr>
         <tr><td class = "b"> Australia</td></tr>
      </table>
      <br />
      <table class = "two">
         <caption>Border Separate</caption>
         <tr><td class = "a"> India</td></tr>
         <tr><td class = "b"> Australia</td></tr>
      </table>
   </body>
</html>

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 31-Jan-2020

115 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements