In this section, you will see the use and implementation of <label> tag.
In this section, you will see the use and implementation of <label> tag.Here, we will introduce you to about the label. The <label> tag is use for adding caption on control. It works as name on form controls. It does not supports for nested label.
Attributes of form:Attribute | Value | Description |
for | id of related control | It specifies related control of form. |
form | id of related form | Identify the form from which it is related. |
<label for="" form=""> Text</label> |
<!DOCTYPE html > <html> <head> <title>Title of document</title> </head><body> <h2>Implementation of label tag of HTML5.</h2> <form id="GenderForm"><table style="width: 49%"> <tr> <td><label for="married"><b>Married</b> </label></td> <td><input type="radio" name="gender" id="married" /></td></tr> <tr><td> <label for="unmarried"><b>Bachelor</b></label></td> <td><input type="radio" name="gender" id="unmarried" /></td> </tr> <tr><td> <label id="age"><b>Age</b></label></td> <td><input type="text" id="age" /></td></tr> <tr><td> <label for="button" >Submit</label> </td> <td> <input type="submit" id="button" /></td></tr> </table> </form></body> </html> |
The label tag is available in both HTML5 and HTML4.01. But there is a form attribute in HTML5, that is not supported by HTML4.01.