Centering a ul...

liunx

Guest
Man, this is making me angry, lol.

Could somoene tell me how to center this ul?

<!-- m --><a class="postlink" href="http://neczy.no-ip.com/new/">http://neczy.no-ip.com/new/</a><!-- m -->

the top links, the ones going horizontal, how can i center that?

Thanks.#navlist {
margin: 0;
padding: 0 0 20px 20%;
border-bottom: 1px dashed #eee;
}

#navlist ul, #navlist li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif, sans;

}
#navlist li {
width: 15%;
display: block;
float: left;
}<div align="center">
<ul id="navlist">
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"#" title="Link 1">Link 1</a></li>
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"#" title="Link 2">Link 2</a></li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"#" title="Link 3">Link 3</a></li>
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"#" title="Link 4">Link 4</a></li>
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"#" title="Link 5">Link 5</a></li>
</ul>
</div>The ALIGN attribute of the DIV tag is invalid HTML, unless you are using a Transitional DTD. I don't think it's valid XHTML in any version, though I could be wrong. Aside from that, I don't think it would work because his DIVs are being floated.Try this instead:#navlist {
margin: 0;
padding: 0 0 20px 10px;
border-bottom: 1px dashed #eee;
text-align:center;
}

#navlist ul, #navlist li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif, sans;

}

#navlist a:link, #navlist a:visited {
/*float: left;*/
line-height: 14px;
font-weight: bold;
margin: 0 10px 4px 10px;
text-decoration: none;
color: #999;
}I'm not sure why you're using float since you have set the <li>'s to display:inline.thanks guys! The float left was orignally for an old layout i made, was recycling code and didn't notice it. Thanks again, the text-align: center worked perfectly!Happy to help. :)Jona,

You're probably right about it not meeting standard or at least not being good practice. I didn't even notice that the listitems were being floated either. :)No problem, Cstick; we all get corrected all the time. In fact... Thanks, Lavalamp, for correcting me. ;) I should have looked more closely.
 
Back
Top