{{ APIRef("HTML DOM") }}
The HTMLLabelElement
interface gives access to properties specific to {{HTMLElement("label")}} elements. It inherits methods and properties from the base {{domxref("HTMLElement")}} interface.
{{InheritanceDiagram}}
Properties
Inherits properties from its parent, {{domxref("HTMLElement")}}.
- {{domxref("HTMLLabelElement.control")}} {{ReadOnlyInline}}
- The control with which the label is associated.
- {{domxref("HTMLLabelElement.form")}} {{ReadOnlyInline}}
- A {{domxref("HTMLFormElement")}} object representing the form with which the labeled control is associated, or
null
if there is no associated control, or if that control isn't associated with a form. In other words, this is just a shortcut forHTMLLabelElement.control.form
. - {{domxref("HTMLLabelElement.htmlFor")}}
- A string containing the ID of the labeled control. This reflects the {{htmlattrxref("for", "label")}} attribute.
Methods
No specific methods; inherits methods from its parent, {{domxref("HTMLElement")}}.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', "forms.html#the-label-element", "HTMLAnchorElement")}} | {{Spec2('HTML WHATWG')}} | No change from {{SpecName("HTML5 W3C")}}. |
{{SpecName('HTML5 W3C', "forms.html#the-label-element", "HTMLAnchorElement")}} | {{Spec2('HTML5 W3C')}} | The property accessKey is now defined on {{domxref("HTMLElement")}}.The following property has been added: control . |
{{SpecName('DOM2 HTML', 'html.html#ID-13691394', 'HTMLLabelElement')}} | {{Spec2('DOM2 HTML')}} | No change from {{SpecName("DOM1")}}. |
{{SpecName('DOM1', 'level-one-html.html#ID-13691394', 'HTMLLabelElement')}} | {{Spec2('DOM1')}} | Initial definition. |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoDesktop(1.0)}} [1] | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoMobile(1.0)}} [1] | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
[1] The form
attribute's meaning was changed in a specification revision on April 28, 2016. Previously, it returned a form with which the label was directly associated. However, labels are no longer members of forms; instead, this attribute now returns the form with which the control
is affiliated.
See also
- The HTML element implementing this interface: {{HTMLElement("label")}}
- {{HTMLElement("form")}}
- {{domxref("HTMLFormElement")}}