Solved

form - input field spacing

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
insert text field data into html script 13 44
Create CSS Animation for Page Transitions 4 28
Wordpress plugins not working in html 3 26
jQuery Sticky Menu 24 22
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 …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

825 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