Easy Tutorial
❮ Prop Attr Value Event Ondragenter ❯

Label htmlFor Attribute

Label Object

Example

Return the value of the label's for attribute:

x Output result:


Definition and Usage

The htmlFor property sets or returns the value of the label's for attribute.

The for attribute specifies which form element a label is bound to.


Browser Support

All major browsers support the htmlFor property.


Syntax

Return the htmlFor property:

Set the htmlFor property:

Attribute Values

Value Description
id The id of the element the label is bound to.

Technical Details

| Return Value: | A string, representing the id of the element the label is bound to. | | --- | --- |


More Examples

Example

Change the value of the label's value attribute:


Related Articles

HTML Reference: HTML <label> for Attribute


Label Object

❮ Prop Attr Value Event Ondragenter ❯