Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: How to center align a form

Tags:

html

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.

like image 809
Marcus Tik Avatar asked Mar 16 '12 12:03

Marcus Tik


People also ask

How do you center align a form in HTML?

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 .

How do I center a form field in Align?

My best bet is text-align:center in a stylesheet on the form tag. that will make all forms on your site center aligned.

How do you center align a form in HTML w3schools?

Center Align Text To just center the text inside an element, use text-align: center; This text is centered.


2 Answers

Just put some CSS into the stylesheet like this

form {   text-align: center; } 

then you're done!

like image 25
mads Avatar answered Oct 12 '22 21:10

mads


@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; } 
like image 93
TryHarder Avatar answered Oct 12 '22 22:10

TryHarder