HTML <label> tag

The <label> tag is used to define a label for an <input> element. Adding this element doesn't affect visually on the relative element.

Type: Inline Element

Basic example

<form>
 <label for="male"> Male: </label>
 <input type="text" id="male">
</form>

The value of the for attribute of the <label> tag should be equal to the value of the id attribute of the <input> tag to make the form more easier to use.

Supported Browsers

Tag Chrome Internet Explorer Firefox Safari Opera Mini
<label> Yes Yes Yes Yes Yes

Full code example

<!DOCTYPE
<html>
<head>
</head>
<body>
 
<form>

<label for="male">Male</label>
<input type="radio" id="male" value="male"> <br>

<label for="female">Female</label>
<input type="radio" id="female" value="female">

</form>
</body>
</html>
Run The code »

Output on the browser


Default CSS property of <label> tag

label {
  cursor: default;
}

Attributes of <label> tag

Attribute Value Notes
for element_id It specifies the ID of the related form field element.
form form_id It specifies one or more forms that the label belongs to.