Using nth-child() non recursive - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:nth-child

Description

Using nth-child() non recursive

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 {<!--from w w w.j  a va  2  s . c o  m-->
   background:white;
}

body>div:nth-of-type(1) {
   background:red;
   color:Chartreuse;
}

body>div:nth-child(2) {
   background:blue;
}
</style> 
 </head> 
 <body> 
  <div>
    Lorem i 
  </div> 
  <div>
    Lorem i 
   <div>
     Lorem ips 
   </div> 
   <div>
     Lorem ips 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials