Skip to content

Files

Latest commit

 

History

History
29 lines (21 loc) · 557 Bytes

label-has-associated-control.md

File metadata and controls

29 lines (21 loc) · 557 Bytes

Pattern: Unassociated form label

Issue: -

Description

Form labels must be associated with their controls either through nesting or using the htmlFor attribute. Unassociated labels prevent screen reader users from understanding the purpose of form controls.

Examples

Example of incorrect code:

<label>Name</label>
<input type="text" />

<label>Email</label>
<CustomInput />

Example of correct code:

<label htmlFor="name">Name</label>
<input id="name" type="text" />

<label>
  Email
  <input type="email" />
</label>