Si8 Si8 - 1 year ago 129
CSS Question

How to horizontally align ul to center of div?

I am trying to center a

inside a
. I tried the following

text-align: center;


left: 50%;

This is not working.


.container {
clear: both;
width: 800px;
height: 70px;
margin-bottom: 10px;
text-align: center;

.container ul {
padding: 0 0 0 20px;
margin: 0;
list-style: none;

.container ul li {
margin: 0;
padding: 0;

I want the
to be centered inside the container.

Answer Source

IE7+: max-width: 660px and margin: auto

You can center a block-level element by assigning a fixed width and margin-right and -left set to auto.

.container ul {
    /* for IE below version 7 use `width` instead of `max-width` */
    max-width: 660px;
    margin-right: auto;


  • No container needed
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download