What is the use of the label tag in HTML?
The <label> tag gives a name to a form field. Connect it with the field by writing the field’s id in the for attribute.
<label for="email">Email:</label>
<input type="email" id="email" name="email">
- Clicking the label puts the cursor in the field, or ticks the checkbox. This makes small checkboxes easy to use on phones.
- Screen readers read the label when the visitor enters the field.
- A
placeholderis not a replacement for a label.
You can also put the input inside the label and skip for. See HTML Forms.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |