Styling an arbitrarily nested list - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:UL Element

Description

Styling an arbitrarily nested list

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ipsum dolo</title> 
  <style type="text/css">
ul, li {
   margin:0;
   padding:0;
   list-style:none;
}

#outer {<!--   ww w . ja v a 2 s  .c o  m-->
   width:301px;
   border:3px solid Chartreuse;
}

#outer ul {
   border-top:2px solid yellow;
}

#outer .level1 li>span {
   padding-left:31px;
}

#outer .level2 li>span {
   padding-left:61px;
}

#outer .level3 li>span {
   padding-left:91px;
}
</style> 
 </head> 
 <body> 
  <ul id="outer"> 
   <li> <span>Lorem </span> </li> 
   <li> <span>Lorem </span> 
    <ul class="level1"> 
     <li> <span>Lorem i</span> </li> 
     <li> <span>Lorem i</span> 
      <ul class="level2"> 
       <li> <span>Lorem ip</span> </li> 
       <li> <span>Lorem ip</span> 
        <ul class="level3"> 
         <li> <span>Lorem ips</span> </li> 
        </ul> </li> 
      </ul> </li> 
    </ul> </li> 
  </ul>  
 </body>
</html>

Related Tutorials