treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Centering

  • I'm pretty new for web designing, And I wanna know, How to position Navigation Bar which created using un-orderd list and image replacement, to center (with every screen resolutions)?
    Thanks! :)
  • If you want to center something you can use margin:auto.


    I made an example for you:
    http://www.cssdesk.com/LM8Aw

    This requires a width however. With navigation if you want to center it there will be issues in the future if you try to add more links.

    Hope that helped!
  • You could use the
    <center> </center>
    or easily make it like this (the recommended way):

    HTML

    <div id="nav">
    <ul>
    <li><a href="#">One</a></li>
    <li><a href="#">Two</a></li>
    <li><a href="#">Three</a></li>
    <li><a href="#">Four</a></li>
    </ul>
    </div>


    CSS

    #nav{
    margin: 0 auto;
    text-alignment: center;
    }

    #nav ul, li{
    display:inline;
    }

    #nav ul{
    list-style-type: none;
    }

  • @SmashDeveloper

    Why even mention the
    <center>
    tag? It's obsolete and is not even part of the HTML5 spec