Web page
Using LABEL objects
The HTML 4.0 specification introduces a LABEL object that you can use to associate text with any other HTML object or internal control. The linked label and HTML object behave consistently when the event is raised and received, regardless of whether the user clicks a label or an HTML object. To link label and HTML objects, set the label's for property to equal the ID property of the HTML object.
The following example associates a LABEL control with a text box. When the user clicks a Label control (or presses the ALT+T key combination), the label control sets the focus to the text box:
The following is a reference fragment:
<input type= "text" id= "Txtinputbox" name= "Txtinputbox" accesskey= "T"/> |
Labels are designed primarily to add accessibility to form components, and we typically use labels in the form. In addition to the above methods, you can embed the entire form component and the text label directly with a label, as in the following example:
The following is a reference fragment:
</form> |
Under
SpecificationThis allows the text to be automatically associated with the adjacent form component, which unfortunately is not supported by IE.