Change the color of <li> parents on hover - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Hover to change Color

Description

Change the color of <li> parents on hover

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">
li a {
   color:Chartreuse;
}

li:hover, li:hover a {
   color:yellow;
   font-weight:bold;
}

li:hover ul a {
   color:blue;
   font-weight:bold;
}

li:hover ul li:hover>a {
   color:pink;
   font-weight:bold;
}
</style> <!--   w w w.ja v a  2  s . c  om-->
 </head> 
 <body> 
  <ul> 
   <li> <a href="#">Lorem </a> </li> 
   <li> <a href="#">Lorem </a> </li> 
   <li> <a href="#">Lorem </a> 
    <ul> 
     <li> <a href="#">Lorem ip</a> </li> 
     <li> <a href="#">Lorem ip</a> 
      <ul> 
       <li> <a href="#">Lorem ipsu</a> </li> 
       <li> <a href="#">Lorem ip</a> 
        <ul> 
         <li> <a href="#">Lorem ipsu</a> </li> 
         <li> <a href="#">Lorem ip</a> </li> 
        </ul> </li> 
      </ul> </li> 
    </ul> </li> 
  </ul>  
 </body>
</html>

Related Tutorials