how to align a button to the center code example

Example 1: 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 2: 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 3: how do you center buttons in css

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

Example 4: html center button

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8" />
      <title>Button align center</title>

      <style>
         .flex-parent {
            display: flex;
         }

         .jc-center {
            justify-content: center;
         }

         button.margin-right {
            margin-right: 20px;
         }
      </style>
   </head>
   <body>
      <div class="flex-parent jc-center">
         <button type="submit" class="green margin-right">Confirm</button>
         <button type="submit" class="magenta">Cancel</button>
      </div>
   </body>
</html>

Example 5: html center button

<center><a href="https://www.google.com"><button>Button Text</button></a></center>

Tags:

Css Example