align button center css code example

Example 1: css align center

//HTML
<div class="parent">
	<span>Hello World</span>
</div>

//CSS
.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}

Example 2: horizontaly center button css

button {
    margin:0 auto;
    display:block;
}

Example 3: html center button

button{
    /*Change the width as much as you like, but make sure 
    margin-left and margin-right + width = 100%*/
    width:50%;
    margin-left:25%;
    margin-right:25%;
}

Example 4: how to make a button centered in html5

<!--Put the button inside a p like this-->
<p style="text-align: center;"><button>See?</button>Whatever</p>

Example 5: how do you center buttons in css

<div style="text-align:center;">
    <button>button1</button>
    <button>button2</button>
</div>

Tags:

Html Example