Discover how a simple link between label and input can make your forms friendly for everyone!
Why Label association in HTML? - Purpose & Use Cases
Imagine you create a form with text boxes and checkboxes. You write the label text next to each input, but you don't connect them properly.
Without linking labels to inputs, screen readers can't tell which label belongs to which input. Users who click the label don't activate the input. This makes forms confusing and hard to use, especially for people with disabilities.
Label association connects a label to its input using the for attribute and matching id. This makes clicking the label focus the input and helps screen readers read the form clearly.
<label>Name</label>
<input type="text"><label for="name">Name</label> <input type="text" id="name">
Forms become easy to use for everyone, including people using keyboards or screen readers.
When filling out a signup form, clicking the "Email" label puts the cursor in the email box, making the process smooth and accessible.
Labels must be linked to inputs for better accessibility.
Use for on labels and matching id on inputs.
This improves usability for all users, especially those with disabilities.