Nth Child in CSS - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:nth-child

Description

Nth Child in CSS

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">
.main:first-of-type .target_me_one {<!--  ww w.  jav a  2 s.c  o m-->
   background:Chartreuse;
}

.main:first-of-type .target_me_two {
   background:yellow;
}
</style> 
 </head> 
 <body> 
  <div class="main"> 
   <div class="color">
     Lorem 
   </div> 
   <div class="number"> 
    <div class="target_div">
      Lorem 
     <div class="target_me_one">
       Lorem ipsu 
     </div> 
     <div class="target_me_two">
       Lorem ipsu 
     </div> 
    </div> 
   </div> 
  </div> 
  <div class="main"> 
   <div class="color">
     Lorem 
   </div> 
   <div class="number"> 
    <div class="target_div">
      Lorem 
     <div class="target_me_one">
       Lorem ipsu 
     </div> 
     <div class="target_me_two">
       Lorem ipsu 
     </div> 
    </div> 
   </div> 
  </div> 
  <div class="main"> 
   <div class="color">
     Lorem 
   </div> 
   <div class="number"> 
    <div class="target_div">
      Lorem 
     <div class="target_me_one">
       Lorem ipsu 
     </div> 
     <div class="target_me_two">
       Lorem ipsu 
     </div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials