English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML label form attribute

The form attribute specifies one or more forms to which the <label> element belongs.

 HTML <label> tag

Online Example

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 ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the form attribute.

Definition and Usage

The form attribute specifies one or more forms that the <label> element belongs to.

HTML 4.01 and HTML5differences between

form attribute in HTML5 New attribute added in

Syntax

<label form="form_id">

Attribute Value

ValueDescription
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.

 HTML <label> tag