what does <label for=...> mean?

hi all,

i'm a ror newbie and so hope you don't mind this simple question. i
was looking at an rhtml file for a form when i ran across this html
code:

<label for="user_username">Username:</label>

what is the <label for=...> tag used for? many thanks for your help!

If you specify the id of an element in your page, when you click the
label it will transfer focus to that element :slight_smile:

Try it:

<label for="foo">Click me!</label>
<input type="text" id="foo">

dparkmit wrote:

thanks! does it do anything else besides that?

dparkmit wrote:

thanks! does it do anything else besides that?
  

Nope, but you can style it as a CSS element :wink:

thanks! does it do anything else besides that?

It's probably very helpful for people with disabilities.

Your question is strictly about HTML, by the way. You may get better
feedback from a mailing list / usenet group specific to that topic.

There's also the w3c consortium's web site, where you can find the
full html specifications; see http://www.w3.org/

HTH,
Isak

In some browsers, radio button and checkbox controls can be clicked on the label in addition to the control itself.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

>
> thanks! does it do anything else besides that?
>

It's probably very helpful for people with disabilities.

Your question is strictly about HTML, by the way. You may get better
feedback from a mailing list / usenet group specific to that topic.

Or, you could go to the official source ... the HTML specification,
which describes all of the legal elements and attributes[1]. I find
the "Index of Elements" and "Index of Attributes" links at the bottom
of the Table of Contents to be incredibly useful reference sources,
and have them both bookmarked.

Craig

[1] http://www.w3.org/TR/html4/