Welcome to WebmasterWorld Guest from 54.146.1.178

Forum Moderators: not2easy

Message Too Old, No Replies

centering a Button

How do i do this?

     
11:48 am on Jul 22, 2013 (gmt 0)

New User

joined:July 22, 2013
posts: 2
votes: 0


hi
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
4:28 pm on July 22, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13821
votes: 483


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>.
4:49 pm on July 22, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts: 5003
votes: 20


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>
10:36 pm on July 22, 2013 (gmt 0)

New User

joined:July 22, 2013
posts: 2
votes: 0


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