Select multiple child elements using nth-child - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:nth-child

Description

Select multiple child elements using nth-child

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">
.one ul li:nth-child(-n+5) {
   color:Chartreuse;
}
</style> <!-- www.  j a v a  2  s  . c  o  m-->
 </head> 
 <body> 
  <div class="one"> 
   <ul> 
    <li>Lor</li> 
    <li>Lor</li> 
    <li>Lorem</li> 
    <li>Lore</li> 
    <li>Lore</li> 
    <li>Lor</li> 
    <li>Lorem</li> 
    <li>Lorem</li> 
    <li>Lore</li> 
    <li>Lor</li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials