<label>
Browser |
|
---|---|
Type |
The LABEL element assign a label to a form field (item).
<label for="item1">Name : </label>
<input type="text" name="name" size="30" id="item1">
Attribute | Value | Explanation |
---|---|---|
for=" " | ID value | matches field ID value |
- Example that doesn't use the LABEL element
-
Even if the label text is clicked, the item cannot be selected.
Yes No Both
- Example that uses the LABEL element
-
The item can be selected by clicking the label text.
Code example :
<input type="radio" name="example" value="Yes" id="yes"><label for="yes">Yes</label>
The value of the for attribute is matched to the value of the id attribute.