I generally prefer using lists to layout forms as it makes more logical sense to me. I'm not sure that there are massive pros and cons either way. Perhaps if you use an ordered list it's an easier way to number the elements of your form if that's appropriate for the particular form.
See this article for more info on styling forms (although I don't think it discusses divs vs list:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
I suppose the "preferred" option would be to use only those elements intended to structure forms - <fieldset>, <label>, <input>, <textarea> and <select>. I've done exactly that at
, the only non-form element is a <h2> for the form title.
However, it's not always possible to do that. A list, ordered or unordered might be appropriate. Another possibility, which I've used effectively in the past, is a definition list with the <label>s in the <dt>s and the <input>s (etc.) in the <dd>s.
Tables are another possibility, and probably no worse than complex nested div structures.
There isn't one answer, though. It depends entirely on the specific situation.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.