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.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.