Set Different border spacing for different rows in a table - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Row

Description

Set Different border spacing for different rows in a table

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

table {<!-- ww  w.ja  v a  2  s . c o m-->
   border-collapse: collapse;
   border-spacing: 1em;
}
table thead {
   border-collapse: separate;
}
table tbody tr {
   border-bottom: 1px solid black;
}
table thead tr th{
   border-bottom: 1px solid black;
   padding: 10px;
   text-align: center;
   position: relative;
}
table tbody tr td {
   border-bottom: 1px solid black;
   padding: 10px;
}
thead th:first-child::after,
thead th:last-child::before {
   content: '';
   position: absolute;
   bottom: -1px;
   width: 0.5em;
   border-bottom: 1px solid #fff;
}
thead th:last-child::before {
   left: 0;
}
thead th:first-child::after {
   right: 0;
}


      </style> 
 </head> 
 <body> 
  <table> 
   <thead> 
    <tr> 
     <th colspan="2"> One </th> 
     <th colspan="2"> Two </th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td> One </td> 
     <td> Two </td> 
     <td> Three </td> 
     <td> Four </td> 
    </tr> 
    <tr> 
     <td> One </td> 
     <td> Two </td> 
     <td> Three </td> 
     <td> Four </td> 
    </tr> 
   </tbody> 
   <tbody> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials