How to Label a Form Field in HTML by Wrapping It in a label
Wrap a form field and the words that describe it in one <label>, and the two belong together: clicking the words works like clicking the field, and screen readers announce the field by those words.
Syntax
<label><field> <text></label>
<label><text> <field></label>
| Part | What it does |
|---|---|
<label> … </label> | The caption of the one form field inside it. |
<field> | A form field, such as <input type="checkbox"> for a checkbox or <input> for a text box. |
<text> | The words that describe the field. They can come before or after it. |
MDN's label page calls this an implicit association: the field is inside the label, so it needs no id.
The Example
The example form has a checkbox for a newsletter, with its words after it, and a text box for an email address, with its word before it. Each field is wrapped in a label with its words.
Step 1: Write the Code
Create a file named index.html in a text editor, such as Visual Studio Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Labels</title>
</head>
<body>
<form>
<p><label><input type="checkbox" name="news"> Send me the newsletter</label></p>
<p><label>Email <input name="email"></label></p>
</form>
</body>
</html>
Step 2: Click the Words
Double-click index.html to open it in your browser. Click the words Send me the newsletter, not the box itself:

The checkbox is ticked. Now click the word Email: the cursor moves into the text box. The screenshot comes from Chromium 159, the open-source browser that Chrome is built on.
What Happened
- Clicking the words ticked the checkbox, because the words and the checkbox are in the same
label. - Clicking Email put the cursor in the text box: Chromium reported the text box named
emailas the focused element. - Each field got its label's words as its name. In Chromium's accessibility tree, the information screen readers use, the checkbox was named Send me the newsletter and the text box Email.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Writing the words next to the field without a label | Clicking the words does nothing: the checkbox stayed unticked, and in Chromium's accessibility tree it had no name at all | Wrap the field and its words in one label |
Putting two fields in one label | The label belongs to the first field only: clicking the words put the cursor in the first text box, and in Chromium's accessibility tree the second one had no name | Give each field its own label |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Clicking the words doesn't tick the checkbox | The words aren't inside the same label as the checkbox | Move both into one label |
| A screen reader announces a checkbox without its words | The checkbox has no label | Wrap it and its words in a label |
FAQ
Should I wrap the field or use the for attribute?
Both connect a label to its field. Wrapping needs no id. The for attribute lets the label and the field sit apart, for example in different cells of a table.
Can the words come before the field?
Yes. In the example, Email comes before its text box, and clicking it still moved the cursor into the box.
Conclusion
Wrapping a field and its words in a label connects them with nothing else to add: the words become clickable, and they become the field's name for screen readers.
Additional Resources
- label: The Label element, on MDN.
