Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Divs or Unordered List for CSS form layout?

Status
Not open for further replies.

fawkes

Technical User
Sep 12, 2003
343
0
0
GB
Which is the preferred option to layout a form for a user to enter new data where the layout is CSS controlled?

Either:
Nested Divs
or
Unordered List

?

Any preferences? Pros/Cons
 
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:

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"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.


-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top