The HTMLLabelElement.htmlFor
property reflects the value of the for
content property. That means that this script-accessible property is used to set and read the value of the content property for
, which is the ID of the label's associated control element.
Syntax
controlId = HTMLLabelElement.htmlFor HTMLLabelElement.htmlFor = newId
Value
A DOMString
which contains the ID string of the element which is associated with the control.
If this property has a value, the HTMLLabelElement.control
property must refer to the same control.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'htmlFor' in that specification. |
Living Standard | Initial definition |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
htmlFor | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support