Home > Net >  How to color tables in css
How to color tables in css

Time:04-25

enter image description here

How can i change the background-color as in the picture in css. Can you please help me.

CodePudding user response:

table, td, th {
  border: 1px solid;
}

table {
  width: 100%; 
  border-collapse:collapse;
}

.left {
  background-color:yellow;
}

.right {
  background-color:red;
}

td{
   height:16px;
}
<table>
 <tr>
  <td colspan="4"></td>
  
 </tr>
 <tr>
  <td colspan="2" class='left'></td>
  <td colspan="2" class = 'right'></td>
 
 </tr>
 <tr>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
 </tr>
</table>

CodePudding user response:

You can simply assign a class to the sections you want to color a class so as to give the background color using this.

  • Related