1. Home
  2. Computing & Technology
  3. Web Design / HTML

<label></label>

By Jennifer Kyrnin, About.com

<label> Description:

The <label></label> assigns an informative label to form controls (one label to one control).

<label> Web Browser Support:

<label> Attributes:

<label> End Tag:

</label> REQUIRED

<label> Contents:

Text CDATA. The following tags are valid within the <label> tag:
a, abbr, acronym, applet, b, basefont, bdo, big, br, button, cite, code, dfn, em, font, i, iframe, img, input kbd, label, map, object, q, s, samp, script, select, small, span, strike, strong, sub, sup, textarea, tt, u, var

<label> Valid Context:

The <label> tag is valid within the following tags:
form

<label> Usage:

  • Standard <label>
    <form>
    <label for="firstname">
    First Name:
    </label>
    <input type="text" name="firstname" id="firstname" />
    </form>
  • <label> surrounding the form element
    <form>
    <label>
    First Name:
    <input type="text" name="firstname" />
    </label>
    </form>

<label> Special Notes:

  • If you place your label in one table cell and the control in another, you will need to use the for attribute to define the explicit control associated with the label.
  • The label can receive focus, with the onfocus attribute. When this happens, the focus is transferred to the associated control.
  • Labels are used by browser agents in different ways, including visually, read aloud, and so on. Be sure to test in several browsers so that it displays as you expect.

More <label> Information:

  • Coming Soon

Return to XHTML Element (HTML Tags) Library

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. HTML Tags
  7. The label Element - form label - XHTML 1.0 HTML 4.0

©2008 About.com, a part of The New York Times Company.

All rights reserved.