Forms & Controls
HTML <label> element
Associates a caption with a labelable form control using for and id, or by containing the control. It improves accessible naming and pointer interaction. Associate the label with the control either by wrapping it or by using for with the control ID. This provides a programmatic name and usually increases the clickable area. Place unrelated interactive content outside the label. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<label for="field">Name</label>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| for | ID | Identifies a labelable control in the same tree. |
Return Value
HTMLLabelElement
Content model: Phrasing content, with no nested label and no labelable descendant other than the labeled control.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <label for="email">Email</label> <input id="email" name="email" type="email"> </body></html>