Skip to content

HTML Tutorial Forms

HTML Labels and Fieldsets: Making Forms Understandable

Lesson 47 of 81 2 min read By Deepak Paswan Updated Oct 4, 2026

A label tells people what a field is for. It is one of the most important accessibility features in HTML.

Connecting a label to a field

Use for on the label with the id of the field:

index.html
HTML
<label for="email">Email address</label>
<input type="email" id="email" name="email">

Or wrap the field inside the label:

index.html
HTML
<label>Email address <input type="email" name="email"></label>

Why labels matter

  • Clicking the label focuses the field, which gives a bigger target on phones.
  • Screen readers announce the label when the field gets focus.
  • Checkboxes and radios become easy to tap.

Grouping with fieldset and legend

fieldset groups related controls. legend is its caption. They are especially important for radio buttons and checkboxes, where each option has its own label but the group needs one too.

index.html
HTML
<form>
  <fieldset>
    <legend>Delivery details</legend>
    <p><label>Street <input type="text" name="street"></label></p>
    <p><label>Town <input type="text" name="town"></label></p>
  </fieldset>
</form>
warning
A placeholder as the only label
Without a real label the field has no name for assistive tools, and the hint vanishes when typing starts. Add a visible label.

Exercise: a labelled field

Write a text input for a “Nickname” with a label correctly connected through for and id.

Show a possible solution
index.html
HTML
<label for="nickname">Nickname</label>
<input type="text" id="nickname" name="nickname">