select all elements excluding a specific one along with all its descendants - HTML CSS CSS

HTML CSS examples for CSS:Selector

Description

select all elements excluding a specific one along with all its descendants

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">
* {<!-- w ww.j  av  a 2 s  . c o m-->
   background-color:Chartreuse;
}

*:not(.exception) {
   background-color:yellow;
}

.exception * {
   background:inherit;
}
</style> 
 </head> 
 <body> 
  <ul> 
   <li>Lorem ipsu 
    <ul> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
    </ul> </li> 
   <li>Lorem ipsu 
    <ul> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
    </ul> </li> 
   <li class="exception">Lorem ipsu 
    <ul> 
     <li>Lorem ipsu 
      <ul> 
       <li>Lorem ip</li> 
       <li>Lorem ip</li> 
       <li>Lorem ip</li> 
       <li>Lorem ip</li> 
      </ul> </li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
    </ul> </li> 
   <li>Lorem ipsu 
    <ul> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
     <li>Lorem ip</li> 
    </ul> </li> 
  </ul>  
 </body>
</html>

Related Tutorials