CSS select child by type only - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:nth-child

Description

CSS select child by type only

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">
ul {<!--from www.  j  a  v a2s  .c  o m-->
   margin:0;
   padding:0
}

.master li {
   width:21px;
   height:21px;
   background:Chartreuse;
   margin:11px;
   list-style:none;
   display:block;
}

.main {
   display:inline !important;
   margin:0 !important
}

li:nth-of-type(2), li:nth-of-type(5) {
   border:3px solid yellow;
}

.master ul li:nth-child(3),.master ul li:nth-child(5) {
   background:green;
}
</style> 
 </head> 
 <body> 
  <ul class="master"> 
   <li></li> 
   <li></li> 
   <li class="main"> 
    <ul> 
     <li></li> 
     <li></li> 
     <li>L</li> 
     <li></li> 
     <li>L</li> 
    </ul> </li> 
   <li></li> 
   <li></li> 
   <li></li> 
   <li></li> 
   <li></li> 
  </ul>  
 </body>
</html>

Related Tutorials