Applying different column styles to table columns - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Column

Description

Applying different column styles to table columns

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">
th, td {
   padding:0.3em 0.5em;
}

td {<!--  w  w w .j  a v  a 2s. c o m-->
   border:2px solid Chartreuse;
}

tr td:nth-child(odd):not(:first-child) {
   background-color:yellow;
}
</style> 
 </head> 
 <body> 
  <table> 
   <thead> 
    <tr> 
     <th></th> 
     <th>Lorem ipsu</th> 
     <th>Lorem ipsu</th> 
     <th>Lorem ipsum </th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td>Lorem i</td> 
     <td>Lorem ipsum dolor</td> 
     <td>Lorem ipsum dolor</td> 
     <td>Lorem ipsum dolor s</td> 
    </tr> 
    <tr> 
     <td>Lorem i</td> 
     <td>Lorem ipsum dolor</td> 
     <td>Lorem ipsum dolor</td> 
     <td>Lorem ipsum dolor s</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials