English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The form attribute specifies one or more forms to which the <label> element belongs.
The <label> element located outside the form (but still part of the form):
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML <label> for Attribute Usage-基础教程(oldtoolbag.com)</title> </head> <body> <p>The label of the first radio button is outside the form, but it is still part of the form. Try clicking the text label to toggle the male radio button.</p> <form action="action_page.php" id="form1"> <input type="radio" name="gender" id="male" value="male"><br> <label for="female">Female</label> <input type="radio" name="gender" id="female" value="female"><br> <label for="other">Other</label> <input type="radio" name="gender" id="other" value="other"><br><br> <input type="submit" value="Submit"> </form> <label for="male" form="form1">Male</label> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the form attribute.
The form attribute specifies one or more forms that the <label> element belongs to.
form attribute in HTML5 New attribute added in
<label form="form_id">
Value | Description |
---|---|
form_id | Specifies the form element to which the <label> element belongs. The value of this attribute must be the id attribute of the <form> element in the same document. |