Saturday, April 19, 2008

[HTML] The under-used <label> tag

I've seen so many web sites not using the label HTML tag. It's a very nifty usability tool whenever you're writing captions for form fields - especially checkboxes and radio buttons.

The problem with checkboxes and radio buttons is that they're small. You have to position your mouse pointer very accurately to be able to turn it on or off. With labels you can associate the form field with its accompanying caption. Clicking on the caption will turn the associated checkbox/radio button on or off. Give it a spin here:

Without the label tag



With text boxes clicking on the label will shift the cursor into the associated text box:

Enter your name (without label):



All you need to do is give the form field an id tag and associate the label with it:
<input type="checkbox" id="example2" /> <label for="example2"> With the label tag</label>

4 comments:

  1. Or you could wrap the form field inside the label tag if you want to avoid the id mappings:

    <label><input ... /></label>

    ReplyDelete
  2. We would like you to write for our products on regular basis. Please email us at seema@spacify.com

    ReplyDelete
  3. Thanks... Your blog helped me in getting Innovation point [:)]

    ReplyDelete