Call me stupid, but i’ve always been told that you can’t center the contents of an unordered list as used in the footer menu for many websites (maybe that goes to show that many people don’t know what they’re on about?) the solution just popped into my head – try it for your self!
styles:
#footer{text-align:center;list-style:none}
#footer li{display:inline}
HTML
<ul id=”footer”>
<li><a href=”1.asp”>Link 1</a></li>
<li><a href=”2n.asp”>Link 2</a></li>
<li><a href=”3.asp”>Link 3</a></li>
</ul>
Simple stuff indeed!
10 comments ↓
Thank you. I was just wondering the same thing and was looking for the solution.
Well-loved. Like or Dislike:
10
3
how would you center the unordered list if the lis were set to display: block (in case i want to have backgrounds on them or set a height)?
Well-loved. Like or Dislike:
6
0
Hi Mary, try display:inline-block where you can set the width and height (not in ie6 tho i think) or you could nest the li making the first li 100% wide.
Well-loved. Like or Dislike:
4
0
I was looking so much for the solution… very simple and works perfect!
Congrats, thanx!
Like or Dislike:
2
0
Hi Mark,
It worked like charm!
Thanks for saving my day
-Rahul
Like or Dislike:
1
0
Thanks, very helpful! I wasn’t sure it could be centered that easily, I’m glad I googled it before creating nested divs and other gnarly stuff like that
Like or Dislike:
1
0
Hi Daniel, thanks i try to come up with elegant solutions that use minimal markup
Like or Dislike:
1
0
I’m trying to do the opposite, I don’t want my list centered. I have it on my footer at http://anytimeteas.com
Here’s my css (warning, I don’t really know what I’m doing). I’d like the lists flush to the left and the headers to each column in the same location, preferably on the left side, directly above each list.
.footer-item {
float: left;
width: 33%;
padding-bottom: 10px;
}
.footer-item ul {
padding-left: 15px;
}
Like or Dislike:
0
0
Hi Brian,
Nice article, it helped me out today
Try to add text-align: left to the footer-item class. it might look almost like you want.
Like or Dislike:
0
0
thanks a lot =) simple solution for an annoying problem..
Like or Dislike:
0
0
Leave a Comment (DON'T SPAM ME)