Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<label>

Diese Übersetzung ist unvollständig. Bitte helfen Sie, diesen Artikel aus dem Englischen zu übersetzen.

Summary

The HTML <label> Element represents a caption for an item in a user interface. It can be associated with a control either by placing the control element inside the label element, or by using the for attribute. Such a control is called the labeled control of the label element.

Content categories Flow content, phrasing content, interactive content, form-associated element, palpable content.
Permitted content Phrasing content, but no descendant label elements. No labelable elements other than the labeled control are allowed.
Tag omission Keine, sowohl das Anfangs- als auch das End-Tag sind erforderlich.
Permitted parent elements Any element that accepts phrasing content.
DOM interface HTMLLabelElement

Attributes

This element includes the global attributes.

accesskey HTML 4 HTML5
A shortcut key to access this element from the keyboard.
for
The ID of a labelable form-related element in the same document as the label element. The first such element in the document with an ID matching the value of the for attribute is the labeled control for this label element.
Note: A label element can have both a for attribute and a contained control element, as long as the for attribute points to the contained control element.
form HTML5
The form element that the label element is associated with (its form owner). The value of the attribute must be an ID of a <form> element in the same document. If this attribute is not specified, this <label> element must be a descendant of a <form> element. This attribute enables you to place label elements anywhere within a document, not just as descendants of their form elements.

Examples

Simple "labeled control" example

<label>Click me <input type="text" id="User" name="Name" /></label>

Using the "for" attribute

<label for="User">Click me</label>
<input type="text" id="User" name="Name" />

Specifications

Specification Status Comment
WHATWG HTML Living Standard
Die Definition von '<label>' in dieser Spezifikation.
Lebender Standard  
HTML5
Die Definition von '<label>' in dieser Spezifikation.
Empfehlung  
HTML 4.01 Specification
Die Definition von '<label>' in dieser Spezifikation.
Empfehlung  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Ja) (Ja) (Ja) (Ja) (Ja)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Ja) (Ja) (Ja) (Ja) (Ja)

Notes

Click events in nested <label> elements

Starting with Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5), a bubbling click event triggers at most one <label>, and the synthetic click event cannot trigger additional <label>s. In Gecko, a click event will still bubble up past a <label>, while in WebKit or Internet Explorer the click event will stop at the <label>. The behavior prior to Gecko 8.0 (triggering multiple <label>s) caused Firefox to stop responding (see Bug 646157).

See also

Schlagwörter des Dokuments und Mitwirkende

 Mitwirkende an dieser Seite: Sebastianz, mostwanted
 Zuletzt aktualisiert von: Sebastianz,