homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

centering a Button
How do i do this?

Msg#: 4595310 posted 11:48 am on Jul 22, 2013 (gmt 0)

im trying to centre a button and i can't get it to work for me. I'd appreciate some input as to how i could do this.
My page width is 920px
the html is as follows
<button><a class="pricebutton" href="price.html" title="pricelist">Find our Pricelist Here<button>

the CSS
a.pricebutton {
display: inline-block;
margin-left: auto;
margin-right: auto;
text-align: center;
color: white;

I have tried text-align: center i have tried display block. i just want it to sit in the middle of my page

thanks in advance



WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Msg#: 4595310 posted 4:28 pm on Jul 22, 2013 (gmt 0)

What are you trying to center? The button or the <a> within the button? The CSS only applies to the <a> element; it says nothing about <button>.


WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member

Msg#: 4595310 posted 4:49 pm on Jul 22, 2013 (gmt 0)

That markup is also invalid.
1. You can't have an <a> within a <button>
2. You didn't close the <a> with a </a> before the closing </button>


Msg#: 4595310 posted 10:36 pm on Jul 22, 2013 (gmt 0)

thanks guys elementery mistakes im just a beginner. its all good now.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved