HTML <label> form Attribute

Definition and Usage

form attribute specifies the form to which the label belongs.

The value of this attribute must be equal to the <form> element The id attribute.

Example

The <label> element outside the form (but still part of the form):

<form action="/action_page.php" id="form1">
  <input type="radio" id="html" name="fav_language" value="HTML"><br>
  <input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  <input type="submit" value="Submit">
</form>
<label form="form1" for="html">HTML</label>

Try It Yourself

Syntax

<label form="form_id">

Attribute Value

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.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support