Solved

form - input field spacing

Posted on 2008-10-20
3
166 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
USE HTML to redirect a webpage to a local Xcel file. 2 40
Split in Javascript 5 31
Javascript to allow login/password authorization 4 30
Wrapper for APPs 9 37
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to dynamically set the form action using jQuery.

896 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

15 Experts available now in Live!

Get 1:1 Help Now