Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

<label>

<label
accesskey=key
class=class
dir=ltr|rtr
for=string
id=value
lang=language
style=style
title=text
</label>

Associates a label with a form control. By associating labels with form controls, you give important hints to users of speech browsers while also allowing visual browsers to duplicate common GUI features (e.g., the ability to click on a text label to select a radio button or checkbox).

Each <label> is associated with one form control. The tag’s content is the label of the form control and may include inline elements such as <img> and <strong>.

The for attribute explicitly specifies the control associated with the <label>. The value of the must match the value of the associated form control's id attribute. In the absence of the for attribute, the <label> must contain the associated form control. This method of implicit association is convenient in many cases, but not an option when the form control and its label are in different table cells, paragraphs, or divisions.

Attributes

accesskey=key

Specifies a shortcut key for the link. You activate the link by pressing Alt and the access key together; like standard menu shortcuts in Windows applications.

class=type

Indicates the class to which the tag belongs. You can use the class attribute in a style sheet to create different styles that you want apply to a single HTML tag. For example, you might create three different styles for a <label> tag. See Using the class attribute as a selector for more details.

dir=ltr|rtr

Specifies the direction of text. This can be left-to-right (ltr) or right-to-left (rtl). For example, English characters are presented left-to-right, Hebrew characters are presented right-to-left.

for=string

References the id= of another tag. Optional when the label is implicitly defined. This is done by wrapping the label around the control the label is specified for.

id=value

Specifies a unique name for the tag. No two tags can have the same id on a single page. The value must begin with a letter followed by any alphanumeric character, a hyphen, an underscore, a colon or a full stop. You use it to reference a unique style for a tag or to manipulate the tag with a script.

lang=language

Specifies which language the <label> tag uses. You can enter any valid ISO standard language abbreviation, for example, “en” for English, “de” for German and so on. For example, <span lang="es">hola! como esta?</span>.

This attribute helps search engines understand different languages as different languages rather than just misspelled English. It may also help spelling and grammar checkers and allow speech synthesizers to use language-dependent pronunciation rules.

style=style

Specifies style information. See Style sheets for more information.

title=text

For information only. Some browsers display the title when you move the mouse over the tag (like a tool tip).