Forum: Ruby on Rails what does <label for=...> mean?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
dparkmit (Guest)
on 2007-07-31 15:23
(Received via mailing list)
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!
Cliff R. (Guest)
on 2007-07-31 15:36
(Received via mailing list)
If you specify the id of an element in your page, when you click the
label it will transfer focus to that element :-)

Try it:

<label for="foo">Click me!</label>
<input type="text" id="foo">
dparkmit (Guest)
on 2007-07-31 15:43
(Received via mailing list)
thanks!  does it do anything else besides that?
Cliff R. (Guest)
on 2007-07-31 15:45
(Received via mailing list)
dparkmit wrote:
> thanks!  does it do anything else besides that?
>
Nope, but you can style it as a CSS element ;-)
Isak H. (Guest)
on 2007-07-31 15:53
(Received via mailing list)
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
Perry S. (Guest)
on 2007-07-31 16:36
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
Rob B. (Guest)
on 2007-07-31 18:12
(Received via mailing list)
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 ;-)

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
Craig McClanahan (Guest)
on 2007-08-07 07:50
(Received via mailing list)
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/
This topic is locked and can not be replied to.