A <label> names an input and — crucially — connects to it so the two work as one. <fieldset> groups related controls. Both are accessibility essentials.
Connecting labels
<!-- for/id association --><label for="email">Email</label><input type="email" id="email" name="email" /><!-- or wrap the input --><label>Email <input type="email" name="email" /></label>
Grouping with fieldset
<fieldset><legend>Contact preferences</legend><label><input type="checkbox" name="email_ok" /> Email me</label><label><input type="checkbox" name="sms_ok" /> Text me</label></fieldset>
Key takeaways
- 01A <label> names an input; connect it via for/id or by wrapping the input.
- 02Clicking a connected label focuses the input; screen readers announce it.
- 03A placeholder is not a label — it vanishes when typing.
- 04<fieldset> + <legend> group related controls (e.g. radio sets).
