Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I center a button in html5?

How do I center a button in html5? by modify the css file. I don't want to use the center tag in the html code.

a.read{
padding:10px 20px;
font-size:14px;
line-height:20px;
background-color:#eba73c;
text-align:center;
color:#fff;
border-radius:5px;
text-decoration:none;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
text-align:center;
display:inline-block;
clear:both
}
like image 468
Anders Avatar asked Dec 26 '22 13:12

Anders


1 Answers

You can apply these styles to the anchor to make it block-level, assign a width, and then adjust its margins like this:

a.read{
   display:block;
   width:100px;
   margin:0 auto;
}

Or apply this to its parent element:

.parent{
   text-align:center;
}
like image 96
Mister Epic Avatar answered Feb 01 '23 20:02

Mister Epic