View Full Version : How do you structure your forms?

10-03-2006, 12:23 AM
I have read too much literature that repetitively reiterates (ha) the need to separate structure from behavior and style . . . and "more importantly" to use proper HTML syntax for marking up your content.

So my question would be this, is there some standard markup you are all using for your form elements? When I began I was using <div class="input"> and <div class="label"> before each label/input element in the form . . . now, I'm just using labels and input tags but this makes it hard to place an error message during validation.

I read one book that said maybe we shouldn't use paragraph elements in forms since they aren't necessarily the proper element. What do you use?

10-03-2006, 12:38 AM
Well a div isn't a bad choice as it doesn't really have much of a meaning... a span would also be acceptable but as it's by default an inline element, the div would be best if you wanted a block element.

You could use line breaks as in the following example but it depends on how much extra markup you wish to use (wrapping each form element in a div) and how much you want to make it 'semantic' I guess.