for

The for attribute links a label to a form control by the control's id, or lists controls an output depends on.

Since HTML 4.0 Spec ↗

Syntax

for="control-id"

Examples

<label for="email">Email</label>
<input id="email" type="email">
Output
Clicking the "Email" label focuses the input because for matches its id.

Notes

The for value must equal the target element's id. This builds the accessible name and enlarges the click/tap target. On <output>, for is a space-separated list of source control ids.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12

See also