HTML label tag

HTML <label> element is used to write a caption or name for the form elements.

<form action="files/labeltag.php" method="post">
  <label>Full name: <input name="fn"> </label> <br>
  <label>Age: <input name="age" type="number"></label> <br>
  <label><input type="submit" name="submit"> </label> <br>
 </form>
</>



Tag Uses

Specific uses of <label> tag

You can use label in two ways.

Firstly you can either place input in the label element.

Secondly, You can use the for attribute of label element to associate it with input element.

Tag omission

Both opening and closing tags are necessary for the label element.

Global Attributes

All the global attributes are applicable on the label element.



Was this article helpful?