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

**URL:** <https://www.ruby-forum.com/t/what-does-label-for-mean/110840>\
**Category:** Rails\
**Created:** [July 31, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840 "2007-07-31T13:23:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [July 31, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/1 "2007-07-31T13:23:25Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [July 31, 2007, 1:36pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/2 "2007-07-31T13:36:27Z")

</div>

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:

Click me!

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [July 31, 2007, 1:43pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/3 "2007-07-31T13:43:27Z")

</div>

thanks! does it do anything else besides that?

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [July 31, 2007, 1:45pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/4 "2007-07-31T13:45:28Z")

</div>

dparkmit wrote:

> thanks! does it do anything else besides that?

Nope, but you can style it as a CSS element 😉

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [July 31, 2007, 1:53pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/5 "2007-07-31T13:53:29Z")

</div>

On 7/31/07, dparkmit [removed\_email\_address@domain.invalid](mailto: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/](http://www.w3.org/)

HTH,  
Isak

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [July 31, 2007, 2:36pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/6 "2007-07-31T14:36:49Z")

</div>

Isak H. wrote:

> On 7/31/07, dparkmit [removed\_email\_address@domain.invalid](mailto: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/](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

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [August 7, 2007, 5:50am UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/7 "2007-08-07T05:50:54Z")

</div>

On 7/31/07, Isak H. [removed\_email\_address@domain.invalid](mailto: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] [HTML 4.01 Specification](http://www.w3.org/TR/html4/)

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [July 31, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/what-does-label-for-mean/110840/8 "2007-07-31T16:12:46Z")

</div>

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](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
