Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spacing between form fields

Tags:

html

css

forms

I have an HTML form element:

<form action="doit" id="doit" method="post">
Name <br/>
<input id="name" name="name" type="text" /> <br/>
Phone number <br/>
<input id="phone" name="phone" type="text" /> <br/>
Year <br/>
<input id="year" name="year" type="text" /> <br/>
</form>

I would like there to be a little more space between the fields, for example, between the lines

<input id="name" name="name" type="text" /> <br/> and Phone number <br/>,

and also between

<input id="phone" name="phone" type="text" /> <br/> and Year <br/>.

How can I do it?

like image 928
Mika H. Avatar asked May 04 '13 21:05

Mika H.


2 Answers

I would wrap your rows in labels

<form action="doit" id="doit" method="post">
    <label>
        Name
        <input id="name" name="name" type="text" />
    </label>
    <label>
        Phone number
        <input id="phone" name="phone" type="text" />
    </label>
    <label>
        Year
        <input id="year" name="year" type="text" />
    </label>
</form>

And use

label, input {
    display: block;
}

label {
    margin-bottom: 20px;
}

Don't use brs for spacing!

Demo: http://jsfiddle.net/D8W2Q/

like image 112
Steve Robbins Avatar answered Nov 08 '22 23:11

Steve Robbins


In your CSS file:

input { margin-bottom: 10px; }
like image 42
Turnip Avatar answered Nov 09 '22 01:11

Turnip