Garry Garry - 6 months ago 5x
HTML Question

Aligning a button to the center

I have a simple submit button. I am wanting to align it to the center. Here is my code:

<input type="submit" name="btnSubmit" value="Submit" onClick="Submit" align="center">

However, it does not work. What is the best/easiest way to do this?



You should use something like this:

<div style="text-align:center">  
    <input type="submit" />  

Or you could use something like this. By giving the element a width and specifying auto for the left and right margins the element will center itself in its parent.

<input type="submit" style="width: 300px; margin: 0 auto;" />