← BYTES
HTML·Intermediate·Ref: 2.2.8

What does the `<label>` element's `for` attribute do, and why does it matter for accessibility?

Have a question about this video? Mention reference 2.2.8 when you contact us.

a.It sets the visual font style of the label text
b.It associates the label with a specific form control by matching the control's `id`, so clicking the label text also focuses/activates the control, and screen readers announce the label when the control receives focus
c.It specifies which form the label belongs to
d.It is purely decorative with no functional effect on the form itself
<label for="email"> paired with <input id="email"> creates a programmatic association the browser and assistive technology both understand -- clicking anywhere on the label text focuses/activates the associated input (especially useful for small checkboxes/radio buttons), and screen readers announce the label's text when that input receives focus, which placeholder text alone cannot reliably replicate.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES228#HTML