Warm welcome to the forums theblizzfreak,
This question
is literally answered everywhere.
With margin: 0 auto, the browser calculates an equal margin on both sides of the button with the equation:
(parent width - button width) / 2 = margin on one sides.
Code:
<!-- Parent (browser knows this width) -->
<div>
<!-- Button -->
<button></button>
</div>
The browser cannot find the auto margin without the width of the button.
Code:
button {
display: block;
width: #px; /* use the width of your button */
margin: 0 auto;
background-color:darkgrey;
position:relative;
}