How to center list tags inside an unordered list?

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2010-04-25T01:28:03Z Indexed on 2010/04/25 1:33 UTC
Read the original article Hit count: 252

Filed under:
|

How can list tags that are given a display:block and are floated left, be centered inside an unordered list.

The HTML:

        <div id="navigation">
            <ul>
                <li>Home</li>
                <li>About Us</li>
                <li>Contact</li>
                <li>News</li>
                <li>Events</li>
                <li>Video</li>
                <li>Photos</li>
            </ul>
        </div><!-- navigation -->

The CSS:

#navigation {
    border: 3px solid orange;
    overflow: hidden;
}
#navigation ul {
    list-style-type: none;
    text-align: center;
}
#navigation ul li {
    float: left;
    display: block;
    padding: 10px 8px;
    border: 1px solid green;
}

© Stack Overflow or respective owner

Related posts about html

Related posts about css