Semantic Markup and Forms [duplicate]
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 ul
s and li
s. 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.
精彩评论