Best practice for form layout in html — table or flow?

后端 未结 5 1039
攒了一身酷
攒了一身酷 2021-02-15 23:08

What is considered the best practice for laying out forms in html? Specifically where you have a set of fields with labels, and possible error indicators. The best I can do is u

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-15 23:45

    Use actual elements for field labels, which is good for usability too, and style them appropriately using CSS.

    For instance,

    Then in your CSS, you could style LABEL elements with, e.g., display:block and a width of your desire, and appropriate clear values.

    For tickbox / radio inputs, the input itself should be inside the element - this means that the label itself should be clickable to select that input, for instance:

提交回复
热议问题