I have
<div id="container">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>
With the following CSS:
#container li {
float:left;
height:33px;
line-height:30px;
text-align:center;
width:auto;
}
#container{
width:600px;
}
However I am having difficulty in horizontally centering the ul inside #container
. It appears that I need a fixed width set on the ul for margin: 0 auto
to work (needs text-align: center
for IE). However I do not want to set a fixed width for the ul as the li items will be dynamic.
Please advise.