How do I center a button in html5?


Tags: css,html5,button,center

Problem :

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
}


Solution :

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;
}

    CSS Howto..

    How to work with gradients in CSS / list of online CSS gradient generators [closed]

    How do you close the CSS preview view in Eclipse?

    How to disable button using jquery in materialize css

    How to make the posts of a content type horizontal scrollabel?

    How to get Bootstrap's “hero-unit” to fit across the entirety of top section?

    How to display a div on hover of button using css

    How to use Segoe Print font in CSS?

    CSS triangle over a div using :before and :after - weird offset, how to fix?

    How to align text within div?

    How do I style the scrollbar of a textarea

    How is a CSS “display: table-column” supposed to work?

    How can I attach a method to an object to change CSS

    How to set CSS position properties to none ?

    How to create slideshow in css without having to make more than one class?

    How to change the css of the div that i just created in code

    How do I vertically align text inside an anchor element, which is nested within an unordered list

    How set font-size in TinyMce

    How to place HTML elements over inline SVG

    Show div on radio button check using JS fallback

    How to change border of div containing radio button when checked

    How can I mix vertically-centered elements with different font sizes and retain consistent line height?

    How To Do A Webkit Slide Cover Page Transition

    Dilemma in deciding how to create CSS for H1, H2, H3 etc

    How do browsers parse/render CSS?

    How to draw solid/dotted/dashed lines using most basic HTML/CSS possible (for tcpdf to render them correctly)

    Hovering over navigation link to show a separate div

    how to remove the border-right for a last child in css

    How to use css to style xhtml markup made only of divs like a table [closed]

    how to make a line between div boxes - simple timeline experiment

    How to use nth-child with only direct children?