English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Das HTML-Label-Element (Tag) stellt eine Erklärung für ein Element in der Benutzeroberfläche dar. Das <label>-Tag wird verwendet, um Titel für Benutzerinput (z.B. <button>, <input>, <meter>, <output>, <progress>, <select> oder <textarea>-Tags) zu generieren. Dieses Tag wird auch als <label>-Element bezeichnet.
Eine einfache HTML-Formular mit zwei Eingabefeldern und zugehörigen Beschriftungen:
!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML5 Verwendung des <label>-Tags (Grund教程网 oldtoolbag.com)</title> </head> <body> <h1>Verwendung von </h1> <form action="demo-form.php"> <label for="company">Firma: </label> <input type="text" name="company" id="company"><br> <label for="address">Adresse: </label> <input type="text" name="address" id="address"><br> <input type="submit" value="Submit"> </form> </body> </html>Testen Sie es heraus ‹/›
IEFirefoxOperaChromeSafari
Derzeit unterstützen die meisten Browser den <label>-Tag.
Der <label>-Tag definiert eine Beschriftung (Markierung) für das <input>-Element. Er wird verwendet, um auf einer Webseite die Titel interaktiver Steuerelemente anzuzeigen.
Das Label-Element zeigt dem Benutzer keine speziellen Effekte an. Es verbessert jedoch die Zugänglichkeit für Mausnutzer. Wenn Sie im Label-Element auf den Text klicken, wird dieses Steuerelement ausgelöst. Das bedeutet, dass der Browser automatisch den Fokus auf den mit dem Label verbundenen Formularsteuerelement verlagert, wenn der Benutzer das Label auswählt.
The for attribute of the <label> tag should be the same as the id attribute of the related element.
Hint:"for" attribute can bind the label to another element. Please set the value of the "for" attribute to the value of the id attribute of the related element.
"form" attribute is HTML5 new attributes.
New: HTML5 New Attribute.
Attribute | Value | Description |
---|---|---|
for | element_id | Specifies which form element the label is bound to. |
formHTML5 | form_id | Specifies one or more forms that belong to the label field. |
<label> Tag supports global attributes, see the complete attribute table HTML Global Attributes.
<label> Tag supports all HTML Event Attributes.