CSS nth Selectors table rows - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Row

Description

CSS nth Selectors table rows

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.special tr:nth-child(odd) td {
   background-color:Chartreuse;
}
</style> <!--  w  w w .  ja v a 2s .  c om-->
 </head> 
 <body> 
  <table class="special"> 
   <tbody> 
    <tr class="r0"> 
     <td>Lorem ipsum</td> 
    </tr> 
    <tr class="r0"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r0"> 
     <td>Lorem ipsum</td> 
    </tr> 
    <tr class="r0"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r0"> 
     <td>Lorem ipsum</td> 
    </tr> 
    <tr class="r0"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
   </tbody> 
  </table> 
  <table> 
   <tbody> 
    <tr class="r0"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r0"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r0"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
    <tr class="r1"> 
     <td>Lorem ipsum dol</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials