views:

21

answers:

1

Why do we use labels in rails? such as in a form_for,

f.label
f.text_field

When you don't use labels, everything still works. So why use them?

+3  A: 

This method generates <label> elements in the output HTML which are used to semantically mark up the form: that is, it assigns semantic meanings to the labels in the form as opposed to the input controls themselves. This is useful for nonvisual browsers such as screen readers etc. which need to make a distinction between different parts of a web page based on their meanings and thus can improve accessibility of web pages to users with visual impairments.

Richard Cook
Like Richard said, this is really important for people that use screen readers to browser the net. For even greater support for them, try adding field_set_tag to group form fields together.
Faisal