Style table with alternate th and td - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Cell

Description

Style table with alternate th and td

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<!--   w w w .  j  a  v a2 s .  com-->
 {
   width:201px;
   border:2px solid Chartreuse;
   text-align:left;
}

th
 {
   background:yellow;
}

td
 {
   background:green;
}
</style> 
 </head> 
 <body> 
  <table cellspacing="0;"> 
   <tbody> 
    <tr> 
     <th colspan="6">Lo</th> 
    </tr> 
    <tr> 
     <td colspan="6">Lo</td> 
    </tr> 
    <tr> 
     <th>Lo</th> 
     <td>Lo</td> 
     <th>Lo</th> 
     <td>Lo</td> 
     <th>Lo</th> 
     <td>Lo</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials