Actually, the proper markup for a label is
HTML Code:
<label for="yourName">Your Name</label><input name="yourName" id="yourName" type="text" size="10">
If you're using XHTML, be sure to self-close the input tag by adding a forward slash (and possibly a space, to inprove readability of the source code) before the closing bracket.
(Ize, glad to see you're using the label element properly! The above was for a reference that others can use.)
As for marking up a select element, with its corresponding options, I'd use a fieldset and legend.
HTML Code:
<form name="exampleForm" action="none">
<fieldset id="basicInfo">
<legend>Your Contact Information</legend>
<label for="yourName">Your Name</label><input name="yourName" id="yourName" type="text" size="10"><br>
<!-- other labels and input fields would go here, like the sender's email address and phone number for instance -->
</fieldset>
<fieldset id="recipient">
<legend>Select Element Fieldset Example</legend>
<select name="sendTo" id="sendTo">
<option>Tom</option>
<option>Richard</option>
<option>Harry</option>
<option>My dog Larry</option>
</select>
</fieldset>
<div>
<input id="submit" type="submit" value="Send Message"> <input id="reset" type="reset" value="Clear Form">
</div>
</form>
Multiple select elements can be marked up this way, and you can also give the fieldset a unique ID (like I did in my example, since ID is a shared attribute common to almost all (X)HTML elements).
Also, if you're using XHTML, be sure to self-close the BR and INPUT elements (as well as other self-closing elements) by preceding the closing bracket with a forward slash (and possibly a space to inprove the readability of the source code)
For accessibility purposes, I think you have to declare a tab order for each of your fieldsets so that people who aren't using (or capable of using) a computer mouse can still navigate through your form (you can probably tell I didn't get a lot of sleep last night, which is why my memory is failing me
)
Bookmarks