<label>

Description

This element creates a label and associates it with another element on the page. The element to which the label is linked must contain the id attribute.

When giving the accesskey attribute of the <label> element a value, pressing ALT and the access key will set the focus on the linked element.

Example


<html>
<body>
  <p>
     If you click on the italic text that follows or press 
     <label for="tb" 
            accesskey="a">Alt+A you will set focus on the text box
     </label> 
     <input id="tb" type="text" value="textbox" size="20"/>
  </p><!--from  ww  w . ja v  a 2 s  . co m-->
</body>
</html>

Click to view the demo

The code above generates the following result.

label




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference