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

Web DevelopmentFront End ScriptsCSS

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>
raja
Published on 17-Apr-2018 11:05:06
Advertisements