CSS Target Selection with + and ~ combinators - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:element not immediately sibling

Description

CSS Target Selection with + and ~ combinators

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <meta name="viewport" content="width=device-width"> 
  <style>
.option~.option li.b {
   background-color:Chartreuse;
}
</style> <!--from  w ww.  j av  a  2s. co  m-->
 </head> 
 <body> 
  <ul> 
   <div class="option"> 
    <li class="b">Lorem i</li> 
   </div> 
   <div class="option"> 
    <li class="a">Lorem i</li> 
   </div> 
   <div class="option"> 
    <li>Lorem ip</li> 
   </div> 
   <div class="option"> 
    <li class="b">Lorem i</li> 
   </div> 
   <div class="option"> 
    <li class="b">Lorem i</li> 
   </div> 
  </ul>  
 </body>
</html>

Related Tutorials