I am happy to present a new thing on CSS Globe: CSSG Collections! Approx. once a months I will design, code and give a way a collection of certain web elements for free. First in the series of CSS(G) collections are web forms. I am giving away 5 uniquely designed and coded web form styles. Hope you'll find them useful!
Take a look at the forms | Download CSSG Forms Collection

If you like these forms and want more of these collections, please consider bookmarking this page to your favourite social bookmarking service :)
In this collection I used my typical form markup. I always use FIELDSET and LEGEND elements although I sometimes hide them. I find FIELDSET element to be very useful in presentation, because I have an extra element without jeopardizing semantics. i.e. I can combine FORM and FIELDSET to achieve double backgrounds, or use them for vertical "sliding-door" as I did in my first example.
Here's my typical markup:
<form id="form5" action="/" method="post"> <fieldset><legend>Contact form</legend> <p class="first"> <label for="name">Name</label> <input type="text" name="name" id="name" size="30" /> </p> <p> <label for="email">Email</label> <input type="text" name="email" id="email" size="30" /> </p> <p> <label for="web">Website</label> <input type="text" name="web" id="web" size="30" /> </p> <p> <label for="message">Message</label> <textarea name="message" id="message" cols="30" rows="10"></textarea> </p> <p class="submit"><button type="submit">Send</button></p> </fieldset> </form>
Also, as an announcement, I am currently developing a jQuery plugin for text fields and text areas that will handle their behavior and validation. Stay tuned for more on this subject.
Tim Wright 14 Jan, 2009
A display:block on the label will give you the same output look.
Kudos on <button> though, very underused element!
my2cents
cssglobe 14 Jan, 2009
ST 14 Jan, 2009
jose 14 Jan, 2009
WebmasterNeal 14 Jan, 2009
Brad Czerniak 14 Jan, 2009
Todd Zaki Warfel 14 Jan, 2009
Flash 14 Jan, 2009
nathaniel 14 Jan, 2009
Noticed you said that you are currently creating a jQuery plugin, will it be able to integrate with the Validate and Forms plugins?
nathaniel
Dr. Ritalin 15 Jan, 2009
It's great. Thank you.
Asger 15 Jan, 2009
Concerning the markup I think divs are the most appropriate tag instead of the p's. Semanticly it's not a paragraph, it's not a list and it's not a definition list - It's a division! One could give the div a semantic class name of 'formelement' if you need a specific hook for you css...
oooh 15 Jan, 2009
cssglobe 15 Jan, 2009
Jimmy 15 Jan, 2009
jessabean 15 Jan, 2009
I agree with Todd in that lists make more sense. Either an ordered list or a definition list.
cssglobe 15 Jan, 2009
Francis Wu 15 Jan, 2009
However, another reason is to avoid styling conflicts and the use of too many style hooks.
If I were to use P to wrap controls, it may conflict with using P to wrap instructions at the beginning of the form.
I also avoid the use of LI to wrap controls because I use those for listing check boxes and radio buttons, which can appear in either lists or inline.
ST 15 Jan, 2009
*response to your twitter question*
Dan B. Lee 15 Jan, 2009
cssglobe 15 Jan, 2009
Mark Aplet 15 Jan, 2009
webdawson 15 Jan, 2009
I don't know why but in most of my projects i use div's to wrap input & label...i'm not the big <p> fan but its also a good way.
Jason Huck 15 Jan, 2009
Vladimir Carrer 15 Jan, 2009
Jimmy 15 Jan, 2009
Jimmy 15 Jan, 2009
Sam Benson 15 Jan, 2009
Vladimir 15 Jan, 2009
Let's start with old Tables, we don't need CSS with the tables. Problem much unnecessary HTML code and the tables shouldn't be use as constructors.
Lists lists are great for making "lists" but not for Form building.Do you thing is natural to put your for inside a list?
Imagine the list and the form together without CSS formatting!? Continue >>
Vladimir 15 Jan, 2009
Then we have p, putting form inside paragraph hmm.No thanks.
My personal logical solution is BR . And the form will look great and natural even without css.And not to mention less code then anything else.
Imagine:
1 2 br
1 2 3 br this is something natural to write
And the last solution just pure CSS, how the HTML code will look like without CSS?
I did a lot of research on web forms and css.My advise use BR!
Luka Vida 15 Jan, 2009
Luka Vida 15 Jan, 2009
Jimmy 15 Jan, 2009
Using a paragraph tag would also be problematic unless using a CSS reset, since paragraphs have differing default margins/paddings for various browsers. It is also my firm belief (as stated above) that paragraphs are for text. The specification would be blatantly violated if you were styling your labels/inputs as block elements.
A DIV makes the most sense according to styling and being in accordance with the HTML spec.
Mark Aplet 15 Jan, 2009
Asger 15 Jan, 2009
Vladimir 15 Jan, 2009
mike 16 Jan, 2009
Jesse 16 Jan, 2009
Dainis Graveris 18 Jan, 2009
Hassan 19 Jan, 2009
Zach 22 Jan, 2009
chris 10 Feb, 2009
If you align inputs in multiple columns with separate fieldset's the tabbing direction will be incorrect. Any suggestions? I can only think of table's being the stable way for multi-column form layouts (bring on display:table)
Ibrahim 9 Mar, 2009
The forms are really good. I like no.3 and no.2
My opinion about mark up is , i prefer divs.
elcodigodebarras 10 Mar, 2009
jason 12 Mar, 2009
Also I too have been using p elements to wrap my labels/form elements but after reading all these opinions I believe I will start using divs since it seems to be the best overall semantically acceptable way to do it.
Kaveh 19 Mar, 2009
thanks again.
Guntas 24 Mar, 2009
dlv 27 Jun, 2009
thanks a lot for share
we will be stay tuned for more of this articles!
adeux
sasdaman 28 Jun, 2009