This is a discussion on "CSS form labels" within the Web Page Design section. This forum, and the thread "CSS form labels are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
CSS form labels
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
CSS form labels
I am using labels to help layout the text in my forms but am wandering how I go about reducing the horizontal space between labels
Here is an example of my form
I also have another question becuase I presume you can't use a table within a form properly. How would I go about displaying the same effect as this but using CSS?
|
|
|
|
#2
|
|||
|
|||
|
Re: CSS form labels
personally i tend to use tables to lay forms out, simply because i veiw them as verging on tabular data.
Doing it with CSS wouldnt be difficult, i should imaging the html would look something like this:
|
|
#3
|
|||
|
|||
|
Re: CSS form labels
Your code as shown will not form an association between the label and input elements. The value of the 'for' attribute of the label should match the 'id' value of the input but you only have 'name' attributes and not 'id's.
You can adjust the spacing between labels and their respective inputs and between lines of labels and inputes by using margin and/or padding attributes. You should not need to use a table to layout your form but some people do find this easier. Some also use the method where each line of the form is enclosed in a <div> element. Feel free to look at the xhtml and css behind this form: http://1ontheweb.net/enquiries.html |
|
#4
|
|||
|
|||
|
Re: CSS form labels
Also I think there is an issue with Safari where the label has to wrap the entire input.. woot!
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#5
|
||||
|
||||
|
Re: CSS form labels
Yeah, that's what I've always done. It seems weird, but the validator doesn't hiccup.
<label for="name">Name: <input type="text" id="name" name="name" /></label> |
|
#6
|
|||
|
|||
|
Re: CSS form labels
AListApart has a great article on making forms without tables:
http://alistapart.com/articles/practicalcss This one is a bit scarier: http://alistapart.com/articles/prettyaccessibleforms I'm not sure about tables with forms... they don't sound like tabular data to me! But what do I know? Snow |
|
#7
|
|||
|
|||
|
Re: CSS form labels
I would say it depends on the form. Very complex forms with loads of inputs etc could easily be done with tables and since most users like to tab through forms why not.
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#8
|
||||
|
||||
|
Re: CSS form labels
The tabindex attibute is beautiful, too.
|
![]() |
| Tags |
| forms, labels |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hiding / Showing form fields based on previous form input | John Alexander Hopper | PHP Forum | 1 | Mar 10th, 2008 11:30 |
| Button and box labels.What is the best way? | Mulith | Starting Out | 17 | Nov 5th, 2007 10:26 |
| Tabs, labels, user group whatsits... | pa007 | Webforumz Cafe | 12 | Sep 30th, 2007 03:12 |
| Control Main Timeline Using a Function (Jumping to a different frame using labels) | JamesHatter | Flash & Multimedia Forum | 1 | Jun 27th, 2007 21:02 |
| Help Please - Radio Button Labels not showing | sandyb | Flash & Multimedia Forum | 0 | Jan 16th, 2006 22:56 |