I have the following HTML code and i want to make my form aligned in center.
<form action="advsearcher.php" method="get"> Search this website:<input align="center" type="text" name="search" /> <input type="submit" value="Search"/> </form>
How can I do that? Thanks in advance.
Use the CSS text-align Property to Center a Form in HTML We can set the value to center to center the form. For example, apply the text-align property to the form tag in the style attribute, and set the property to center . Next, create input tags with the type text and then submit .
My best bet is text-align:center in a stylesheet on the form tag. that will make all forms on your site center aligned.
Center Align Text To just center the text inside an element, use text-align: center; This text is centered.
Just put some CSS into the stylesheet like this
form { text-align: center; }
then you're done!
@Lucius and @zyrolasting have it right.
However, you will probably need to give the form a specified width
for it to work properly.
form { margin: 0 auto; width:250px; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With