Horizontally center a button element in a div element - HTML CSS CSS Form

HTML CSS examples for CSS Form:input button layout

Description

Horizontally center a button element in a div element

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

div {<!--   ww  w.  ja v  a 2 s  .co  m-->
   width: 200px;
   height: 100px;
   background: #ccc;
}
button{
   margin: 0 auto;
   display: block;
}


      </style> 
 </head> 
 <body> 
  <div> 
   <button>Button</button> 
  </div>  
 </body>
</html>

Related Tutorials