How to set the width of a form tag?

How can I set the width of the form?

Javier

+5
source share
5 answers

Um ... just like for any other element?

<form style="width: 500px">

(or equivalent setting in CSS class, which is cleaner)

this, however, only works if the form is not set to display: inline. In this case, you cannot specify the width.

+17
source

In the same way, you give the width to any other block element.

You use the width property and selector that matches the element.

eg.

form {
    width: 20em;
}
+2
source

, CSS:

form
{
   width: 120px;
}

<fieldset>:

<form>
   <fieldset>
   name: <input name="realname"><BR>
   email: <input name="email">
   </fieldset>
</form>

fieldset
{
   width: 120px;
}

, .

, .

+2
<form style="width: 100px;">

</form>
0
source

in css add

.form {
width:500px;
}

and then in your html add it as a class to your form. like this form class = "

You will have clean markup, please avoid inline styles.

0
source

All Articles