Core HTML

Form - Label

This form example demonstrates how to code a form with a label tag in it. The label tag uses the for property set to the id of element it is labeling to determine the element that shoould be labeled. Alternatively, the element can be nested inside the label with no for property specified. Both of these types are shown below.

LabelForm.html

<!DOCTYPE html>
<html>
  <head>
    <title>XoaX.net's HTML: Form - Label Tag Example</title>
  </head>
  <body>
    <form>
      <label for="username">Name:</label>
      <input type="text" name="username" value="George Washington" /><br /><br />
      <label for="male">Male
      <input type="radio" name="gender" id="male" value="male" checked/></label>
      <label for="female">Female
      <input type="radio" name="gender" id="female" value="female" /></label>
    </form>
  </body>
</html>
 

Output

 
 

© 2007–2025 XoaX.net LLC. All rights reserved.