Color every other row black using :nth-child(odd) - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Color

Description

Color every other row black using :nth-child(odd)

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">

div.dataset:nth-child(odd) {
   background: black;
   color:white;
}


      </style> 
 </head> <!-- w w  w  .  j ava 2  s .  com-->
 <body> 
  <div class="container"> 
   <div class="dataset">
     Thomas Jones 
   </div> 
   <div class="dataset">
     Edward Jones 
   </div> 
   <div class="dataset">
     Tommy Lee 
   </div> 
   <div class="dataset">
     Jenna Haze 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials