By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

HTML Label

Can be used to describe input fields in a form.

Edited: 2016-01-09 06:39

The HTML label element is used to attach a label to form input elements, and can be used to describe the elements to the user.

To use the label element with form input fields, the for attribute should be used, given a value that matches that of the ID of the input field.

For example, if we create a simple form that submits a name, than the markup would look like:

<form action="action.php" method="post">
 <label for="name">Name:</label>
 <input type="text" name="name" id="name">
 <input type="submit" value="Submit">


Attribute: Value: Description:
Global Attributes Varies The Global attributes can be used on any HTML element.
form Must match the ID of the form element. Used to associate the label with a form element.
for Must match the ID of the control. Used to associate the label with a form control. I.e.: input and textarea.