0

So I have a menu at the top of my page, but I can't figure out how to add spacing in between buttons. I just want a bit of space in between buttons so they don't look so sloppy.

Here's my menu. The code is below it.

enter image description here

HTML:

<div>
  <ul class="topbar">
    <a href="pages/index.html" class="fade">Home Page</a>
    <a href="pages/userprofile.html" class="fade">Profile</a>
    <a href="pages/createacc.html" class="fade">Create an Account</a>
    <a href="pages/settings.html" class="fade">User Settings</a>
    <a href="pages/contact.html" class="fade">Contact Us</a>
  </ul>
</div>

CSS

ul
{
    list-style-type: none;
    padding:0;
    margin:0;
}

/****************************/

.topbar {
    width: 700px ;
    Height:initial;
    background-color: #2b2b2b;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
Brandroid
  • 266
  • 1
  • 2
  • 10

3 Answers3

2

Your "buttons" should be placed inside list items <li>

<div>
  <ul class="topbar">
    <li><a href="pages/index.html" class="fade">Home Page</a></li>
    <li><a href="pages/userprofile.html" class="fade">Profile</a></li>
    <li><a href="pages/createacc.html" class="fade">Create an Account</a></li>
    <li><a href="pages/settings.html" class="fade">User Settings</a></li>
    <li><a href="pages/contact.html" class="fade">Contact Us</a></li>
  </ul>
</div>

And about styling and spacing...

ul.topbar {
    width: 700px ;
    background-color: #2b2b2b;
    margin:0;
    padding:0;
}

ul.topbar li
{
    list-style-type:none;
    display:inline-block;
    padding:0 10px;
}

ul.topbar a
{
    font-family:Arial;
    color:#950095;
    text-decoration:none;
}

ul.topbar a:hover
{
    color:#FFF;
    text-decoration:underline;
}

And you can check it out here:

If for some sort of weird reason, you do not have access to the code generating the menu, you could use some jQuery to wrap <li> around your <a>:

$( "ul.topbar a" ).wrap( "<li></li>" );
Gogutz
  • 2,005
  • 17
  • 19