Center an unordered list - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:UL Element

Description

Center an unordered list

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-home {<!-- w  ww .j  av  a  2  s. c om-->
   border:2px solid Chartreuse;
   margin:0 auto;
   width:71%;
   text-align:center;
}

#li-home {
   display:inline-block;
   padding-right:21px;
}

#a-home:link, #a-home:visited {
   color:yellow;
   background-color:blue;
   padding:21px;
   text-decoration:none;
   font-weight:bold;
}

#a-home:hover, #a-home:active {
   background-color:pink;
}

#a-home {
   width:201px;
   display:inline-block;
}
</style> 
 </head> 
 <body> 
  <ul id="ul-home"> 
   <li id="li-home"> <a id="a-home" href="search.php">Lorem ipsum dolor sit amet, consectetur adipi</a> </li> 
   <li id="li-home"> <a id="a-home" href="my_bookings.php">Lorem ipsum dolor sit amet, consectetur ad</a> </li> 
  </ul>  
 </body>
</html>

Related Tutorials