Add a label for a form control in HTML?

HTMLWeb DevelopmentFront End Technology

The HTML <label> tag is used to add a label to a form control like text, textarea etc. The HTML <label> tag also supports the following additional attributes −

Attribute
Value
Description
form
form_id
It specifies one or more forms the label belongs to
For
control id
This value must be the same as the value in the input control's "id" attribute.

Example

You can try to run the following code to add a label in HTML −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML label Tag</title>
   </head>
   <body>
      <label for = "email">EMAIL-ID:<br />
      <input type = "email" value = "" name = "emailid"
      size = "30" placeholder = "Enter a valid email address">
      <br />
      <br />

      <label for = "phone">PHONE NO:<br />
      <input type = "text" value = "" name = "phno"
      size = "30" maxlength = "10" placeholder = "Enter a valid phone number"
      pattern = "[0-9]{10}">
      <br />
      <br />
   </body>
</html>
raja
Published on 13-Mar-2018 12:02:50
Advertisements