HTML Tag:

Posted: January 20, 2009 in HTML

There’s an interesting HTML tag that I just learned about:

Uses:

<label>
First Name:
<input type="text" name="firstname" />
</label>

OR

<label for="firstname">First Name:</label>
<input type="text" name="firstname" id="firstname" />

The label tag associated the text inside to the input field. There are two advantage to this.

  • For a disabled user, the screen reader can read to the visitor what this field is asking for.
  • The standard user can click on the label which will bring focus to the input field, similar to many desktop applications.

Internet Explorer will only support the second example above to allow clicking of the label. Also think of the advantage of styling the label tag in CSS. So I’d recommend using the second example above. The for attribute references the id attribute in the input tag.

A good video to watch: Creating Attractive, Usable, and Accessible Forms. This was a presentation at Adobe Max 2008.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s