Make alternating CSS table row style work - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Row

Description

Make alternating CSS table row style work

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <meta name="viewport" content="width=device-width"> 
  <!--[if lte IE 9]>
<script src="https://rawgit.com/roylory/ie7-js/master/lib/IE9.js"></script>
<![endif]--> <!--   www  . j  a v a 2s. c om-->
  <style>
table {
   width:100%;
}

tr:nth-child(2n) td {
   background-color:Chartreuse;
}
</style> 
 </head> 
 <body> 
  <table> 
   <tbody> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>Lor</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials