Is "label for" better?

I’ve noticed that it is common practise in forms to use:

<label for=“tablename”,“columnname”> …Some column name

Why is the above construct better than just writting it this way?

Some column name

If there is not compelling reason, I’d prefer to use the second example
and
save on typing.

<label for=“tablename”,“columnname”> …Some column name

Why is the above construct better than just writting it this way?
The ‘for’ attribute specifies which input field the label refers to.
This is an HTML thing rather than specifically Rails.

It’s an accessbility feature, generally important for voice and text
browers.

Also, if you click a label that has a ‘for’ attribute, the assocatied
input field will be selected.

Steve

OK, its worth a little extra typing for accessibility.

Is there a way to change the associated input field’s background color ?
-Larry

you could hack together support for it in internet explorer using event
listeners (onfocus, etc), temporarily adding a “focus” classname while
the form element is focused. the last part is pretty simple with
prototype, ie:

Element.classNames( “my_form_input” ).add( “focus” );

and the CSS:

input.focus, textarea.focus {
background-color: #ffc;
}

On 02 Jul 2006, at 18:00, Larry K. wrote:

OK, its worth a little extra typing for accessibility.

Is there a way to change the associated input field’s background
color ?

input:focus, textarea:focus {
background-color: #ffc;
}

or just
input, textarea {
background-color: #ffc;
}

That’s for the browsers that support it of course (i.e. you can
forget about :focus on Internet Exploder)

Best regards

Peter De Berdt