Exclude last two child elements with CSS selector - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:element parent child

Description

Exclude last two child elements with CSS selector

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">
#parent>div:not(:nth-last-of-type(-n+2)) {
   border-bottom:2px solid Chartreuse;
}
</style> <!--from  w ww .  j  a  v a  2 s .c om-->
 </head> 
 <body> 
  <div id="parent"> 
   <div>
     Lorem 
   </div> 
   <div>
     Lorem 
   </div> 
   <div>
     Lorem i 
   </div> 
   <div>
     Lorem 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials