label element
The HTML element that names a form control; its for attribute (htmlFor in React) holds the control's id.
In more detail
A linked label gives the control its accessible name and makes clicking the label focus the control. React uses htmlFor because for is a reserved word in JavaScript.
Example
<label htmlFor={inId}>Email</label><input id={inId} />Related terms
- form control — An element that collects user input, such as a text input, checkbox, switch, select or button.
- accessible name — The text assistive technology uses to identify a control, such as "Delete account" for a button.
- useId — The React hook that generates a unique ID string that is stable across renders and matches between server and browser.
- accessibility — Designing and building products so that people with disabilities, including those who use keyboards, screen readers or magnifiers, can use them fully.
- ARIA — The W3C standard of HTML attributes, such as role and aria-expanded, that tell assistive technology what a custom widget is and what state it is in.
Taught in
- Actionable Form Primitives: Buttons, Switches & Inputs — Design Systems & Component Engineering
- WAI-ARIA Semantics: Roles, States & Accessible Name Computation — Design Systems & Component Engineering
- useId: Generating Stable Accessible Form Element Identifiers — React 19 & Modern Component Architecture