method

label_tag

label_tag(name = nil, content_or_options = nil, options = nil, &block)
public

Creates a label element. Accepts a block.

Options

  • Creates standard HTML attributes for the tag.

Examples

label_tag 'name'
# => <label for="name">Name</label>

label_tag 'name', 'Your name'
# => <label for="name">Your Name</label>

label_tag 'name', nil, :class => 'small_label'
# => <label for="name" class="small_label">Name</label>

3Notes

unobstrusive label tag

grosser · Sep 18, 20081 thank

just use
label_tag('a_a','a_a') and it works, just not ment for pure decorative labels :)

removes underscores -> do not use for images etc

grosser · Sep 17, 2008

example #does not work label_tag('aa'+image_tag('x_x.gif'))

Html inside Lable tag

taimoorchangaiz · Jun 5, 2013

I need this