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


#1

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:

Username:

what is the tag used for? many thanks for your help!


#2

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:

Click me!


#3

thanks! does it do anything else besides that?


#4

dparkmit wrote:

thanks! does it do anything else besides that?

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


#5

On 7/31/07, dparkmit removed_email_address@domain.invalid wrote:

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


#6

Isak H. wrote:

On 7/31/07, dparkmit removed_email_address@domain.invalid wrote:

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/

Sorry to prolong the pain… but the instructions for the Ajax /
prototype (the thing that does auto complete in particular) tells you to
put a label for the element that the drop down list applies to. I’m not
clear exactly what the label provides that the id of the element does
not.

Come someone explain it to me or point me to a page that does?

Thanks,
Perry


#7

On 7/31/07, Isak H. removed_email_address@domain.invalid wrote:

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/


#8

On Jul 31, 2007, at 7:44 AM, Cliff R. wrote:

dparkmit wrote:

thanks! does it do anything else besides that?

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

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

-Rob

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid