The <label> element
An <label>
element associates a text label with a form <input>
field and is implemented using the DOM HTMLLabelElement
interface. The label can tell users what value should be entered in the input field. Having labels helps the accessibility of a form. You can implicitly or explicitly associate a label with a form. When doing it explicitly, you use the for attribute
, and implicitly, you nest the <input>
directly inside the <label>
.
Technical summary
Content categories | Flow content, phrasing content, interactive content, form-associated element, palpable content. |
---|---|
Permitted content |
Phrasing content, but no descendant label elements. No
labelable
elements other than the labeled control are allowed.
|
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | Any element that accepts phrasing content. |
Implicit ARIA role | No corresponding role |
Permitted ARIA roles | No role permitted |
DOM interface | HTMLLabelElement |