Course contentsShow
← Web Development
Lesson 1003 of 2,98218. Accessibility FundamentalsFree lesson

Form Labels and Input Association

Learn how explicit label associations ensure screen readers announce field purposes correctly.

Form Labels and Input Association

You'll learn: How to explicitly link form labels to inputs so screen readers can correctly announce what each field is for.

Why It Matters

Imagine walking into a room where someone points to random objects without saying what they are. That's what a form without proper label association feels like to a screen reader user. When labels aren't explicitly connected to their inputs, assistive technology can't announce "Email address" when you focus on the email field—it might just say "edit text, blank."

The Core Concept

In HTML forms, a <label> describes what information an input field expects. But proximity isn't enough. You must explicitly associate the label with its input so screen readers understand the relationship.

There are two ways to create this association:

1. Using the for Attribute

Link the label's for attribute to the input's id:

<label for="email">Email address</label>
<input type="email" id="email" name="email">

The for value must exactly match the input's id. Now when a screen reader focuses on the input, it announces "Email address, edit text."

2. Wrapping the Input (Implicit Association)

Place the input inside the label element:

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

While this works, the for/id method is generally preferred because it's more flexible and universally supported.

The Bonus Benefit

Proper association also improves usability for everyone: clicking the label text will focus the input field, making it easier to select—especially helpful for small checkboxes or radio buttons.

Key Takeaway: Always associate form labels with inputs using matching for and id attributes—it ensures screen readers announce field purposes correctly and improves usability for all users.