开发者

Semantic Markup and Forms [duplicate]

This question already has answers here: Why use definition lists (DL,DD,DT) tags for HTML forms instead of tables? (11 answers) Closed 8 years ago.

Currently, my form looks like this:

<label for="comment">Comment:</label>
<textarea name="comment" id="comment" rows="6" cols="20"></textarea><br />

<label for="checker">Check the box:</label>开发者_开发技巧
<input type="checkbox" name="checker" id="checker" value="ON" />

Should these then be converted to <dt>/<dd> since they're somewhat definition lists, or am I taking this too far?


You would be taking it too far unless there is another reason to add definitions to your form. Definitions are not semantically applicable to forms.


It's absolutely fine as it is, leave it be if it works.

If you need surrounding containers around the label/input pairs, add uls and lis. I think they are the semantically more correct choice here.


I tend to use fieldsets to group related fields as appropriate, and then a OL around them. Each LI has a label and an input. They aren't really definitions, more a list of things.


Unless you expect this HTML to be consumed by some particular tool or other automated service, DL/DT is not appropriate. A form is not a glossary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜