Name

label

Synopsis

<label>...</label>

Used to attach information to controls. Each label element is associated with exactly one form control. The label element may contain the form control, or it may use the for attribute to identify the control by its id value.

Attributes

Core(id, class, style, title), Internationalization, Events, onfocus, onblur

accesskey=" character "

Assigns an access key (keyboard shortcut) to an element for quicker access.

for=" text "

Explicitly associates the label with the control by matching the value of the for attribute with the value of the id attribute within the control element.

Example

<label>No thanks <input type="checkbox" name="list" value="no" /></label>

<label for="lastname">Last Name: </label>
<input type="text" id="lastname" size="32" />

Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.