Solved

form - input field spacing

Posted on 2008-10-20
3
165 Views
Last Modified: 2013-11-19
having built a form and noticed the difference is field lengths proving to make it all look very untidy, I was wondering if it was possible to space the label out so they appear on the left and the field text input  boxes all started from the same place so it flows nicely down the page in a line. I know i can have some control over this with the" position: absolute " but was wondering if there was a better or easier way?

i also tried using the <p class="tag1"> but it then puts the field onto a new line??

any ideas
0
Comment
Question by:therob1
3 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 22757526
an "EASY" way is to use tables and just seperate the label/form field in different TD columns.

You should be able to use stylesheets as well and a spacing length for the label and the form field.
0
 
LVL 42

Accepted Solution

by:
David S. earned 60 total points
ID: 22760010
Here's an example of how I prefer to do form layouts: http://www.dynamicsitesolutions.com/css/form-layout-example/
0
 
LVL 3

Assisted Solution

by:sbickerstaff
sbickerstaff earned 60 total points
ID: 22761452
using css only (having all textboxes / selects etc alligned left to the same point and all labels alligned right so they are all beside the boxes):

label {
  text-align: right;
  float: left;
  display: block;
  margin: 0 2px 0 0;
  width: 8em;
}

and then have (for example):

<div>
  <label for="username">Username:</label>
  <input type="text" name="username" id="username" />
</div>
<div>
  <label for="password">Password:</label>
  <input type="password" name="password" id="password" />
</div>

i would not recommend using tables as a lot of developers are moving towards using divs + css for layout instead of tables (if they're not alrady using that)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now