CSS selector with class a but not class b - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:not

Description

CSS selector with class a but not class b

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.classa:not(.classb):not(:last-child) {
   color:Chartreuse;
}
</style> <!--from   w  ww.  j  av  a 2 s.c o m-->
 </head> 
 <body> 
  <div class="container"> 
   <div class="classa classb">
     Lorem ipsum do 
   </div> 
   <!-- Dont Select --> 
   <div class="classa">
     Lorem ip 
   </div> 
   <!-- Select --> 
   <div class="classa">
     Lorem ipsum do 
   </div> 
   <!-- Dont select last instance --> 
  </div>  
 </body>
</html>

Related Tutorials