Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center Text on a Button

Tags:

css

button

center

I know this has been asked a couple of times before, but not of the solutions seem to be working in this case. Basically, I want the word "play" to be centered vertically and horizontally on this button. Horizontally, the text behaves itself, but vertically, not matter what I try, it is always a little bit lower than it should, in all browsers I test it on. Does anyone have any suggestions? Thanks

<style type="text/css">
button {
font-family: Verdana, Geneva, sans-serif;
color: white;
border-style: none;
vertical-align: center;
text-align: center;
}

button:hover {
cursor: pointer;
}

button::-moz-focus-inner /*Remove button padding in FF*/
{ 
border: 0;
padding: 0;
}


.start {
background-color: #0C0;
font-size: 2em;
padding: 10px;

}


</style>
<button type="button" class="start">play</button>
like image 275
Lars Avatar asked Feb 28 '26 12:02

Lars


1 Answers

The padding on .start is likely what you'll have to play around with, although the way it's set, it should be centering it, but you can break it out to something like padding: 8px 10px 10px 10px;

You might also check and set the line-height under .start and see if it helps.

like image 61
Doozer Blake Avatar answered Mar 03 '26 06:03

Doozer Blake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!