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

HTML Reference Manual

HTML Tag大全

HTML label for attribute

for attribute specifies which form element the label is bound to.

 HTML <label> tag

Online Example

Three radio buttons with labels:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <label> for Attribute Usage-Basic Tutorial(oldtoolbag.com)</title>
</head>
<body>
<p>Click the text label to switch options</p>>
<form action="action_page.php">
  <label for="male">Male</label>
  <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>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the for attribute.

Definition and Usage

The for attribute specifies the form element that the label is bound to.

HTML 4.01 and HTML5differences between

None.

Syntax

<label for="element_id">

Attribute Value

ValueDescription
element_idThe id of the element bound to the label.
 HTML <label> tag