change <tr> color after one another - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:after

Description

change <tr> color after one another

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 tr:nth-of-type(odd) {
   color:Chartreuse;
}

table tr:nth-of-type(even) {
   color:yellow;
}
</style> <!--from  ww  w. j  a v a 2s  .  c  o  m-->
 </head> 
 <body> 
  <table> 
   <tbody> 
    <tr> 
     <td>Lorem</td> 
    </tr> 
    <tr> 
     <td>Lorem</td> 
    </tr> 
    <tr> 
     <td>Lorem</td> 
    </tr> 
    <tr> 
     <td>Lorem</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials