This question has been asked several times here at SO, you can do a simple search and find many solutions.
But here is a simple form to get started:
HTML
<form> <div class="line"> <label for="input">Full Name</label> <div class="input"> <input type="text" size="30" name="input"> </div> </div> <div class="line"> <label for="input">Company</label> <div class="input"> <input type="text" size="30" name="input"> </div> </div> <div class="line"> <label for="nselect">Dropdown Menu</label> <div class="input"> <select name="select"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </div> </div> <div class="line"> <label for="input">Text 1</label> <div class="input"> <input type="text" size="30" name="input"> </div> </div> <div class="line"> <label for="input">Text 2</label> <div class="input"> <input type="text" size="30" name="input"> </div> </div> <div class="line"> <label for="input">Text 3</label> <div class="input"> <input type="text" size="15" name="input"> </div> </div> </form>
CSS
form { margin:10px 0; } label { color: #404040; float: left; font-size: 13px; line-height: 18px; padding-top: 6px; text-align: right; width: 130px; } label, input, select, textarea { font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 13px; font-weight: normal; line-height: normal; } input, textarea, select { -moz-border-radius: 3px 3px 3px 3px; border: 1px solid #CCCCCC; color: #808080; display: inline-block; font-size: 13px; height: 18px; line-height: 18px; padding: 4px; width: 210px; } select { height: 27px; line-height: 27px; } form .input { margin-left: 150px; } form .line { margin-bottom: 18px; }
Here is a demo: http://jsfiddle.net/5aduZ/1/
Many people will not agree with my use of divs to separate form elements, but through testing I found that this format is the safest and most reliable way to do this, since it separates fields perfectly and it works fine under IE. In addition, it is a format used by big boys (facebook, twitter, google).
Andres Ilich Jan 08 '12 at 19:52 2012-01-08 19:52
source share