p vs. ol or ul for form styling

前端 未结 7 1814
醉梦人生
醉梦人生 2021-02-01 07:16

Typically I style forms with the unordered list tag e.g.

7条回答
  •  [愿得一人]
    2021-02-01 07:32

    I tend to use ordered lists

    My semantic reasoning for using ordered lists is that a good deal of forms in print are actually numbered and are therefore an ordered list of form inputs.

    Semantically, I think a definition list holds water as well, and it does have the added benefit of supplying a wrapper for every label/input pairing as well as each individual label and input which can give you a lot of design control (if you can live with the slight heavy-handedness of wrapping a DL around each label/input pair)

    If ordered/unordered/definition lists just aren't your thing, then I'd go with divs. Their only implied semantics are "a division" so they are fine for the job.

    I have a hard time justifying the use of paragraph (p) elements to wrap label/input pairs as the implied semantics of the p element just don't apply in my opinion. (also, it's nice to keep the p element available for use inside the form for explanatory text if needed)

提交回复
热议问题