Centering li without adding margin to the last item - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:UL Element

Description

Centering li without adding margin to the last item

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<!--  w  w w.ja va  2  s.  co m-->
 {
   float:left;
   margin:51px 0 51px 100px;
}

li:first-child
 {
   margin:51px 0;
}

ul
 {
   width:401px;
   margin:auto;
}
</style> 
 </head> 
 <body> 
  <ul> 
   <li>Lorem</li> 
   <li>Lorem </li> 
   <li>Lorem</li> 
  </ul>  
 </body>
</html>

Related Tutorials