Child selector to target only the parent items and child items - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:element parent child

Description

Child selector to target only the parent items and child items

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
  <style type="text/css">
ul.parentList li {
   color:Chartreuse;
}

ul.childList li {
   color:yellow;
}
</style> <!--from  w  w  w.  ja  v  a2s  .  c om-->
 </head> 
 <body> 
  <div id="container"> 
   <ul class="parentList"> 
    <li>Lorem ipsum dolor 
     <ul class="childList"> 
      <li>Lorem ipsum dolor</li> 
     </ul> </li> 
    <li>Lorem ipsum dolor </li> 
    <li>Lorem ipsum dolor </li> 
    <li>Lorem ipsum dolor </li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials