Center align buttons (CSS 3)

Munesawagi picture Munesawagi · Oct 17, 2015 · Viewed 16.4k times · Source

I'm looking to center align two buttons using CSS 3. So far, I have this code. Right now, the buttons are left-aligning by default. Any help would be great.

HTML:

<ul>
<li class="menubutton"><a href="about.html">About</a></li>
<li class="menubutton"><a href="staffing.html">Staff</a></li>
</ul>

CSS:

.menubutton{
        text-align: center;
        background-color: beige;
        height: 50px;
        width: 100px;
        border-radius: 5px;
        display: inline-block;
}

Answer

Bak picture Bak · Oct 17, 2015

You should have the <ul> like this:

<ul>
<li class="menubutton"><a href="about.html">About</a></li>
<li class="menubutton"><a href="staffing.html">Staff</a></li>
</ul>

and the css:

ul{
text-align: center;
}