XML technologies / HTML & XHTML / Alphabetical list of HTML and XHTML elements / label

(Excerpt from "HTML & XHTML ─ kurz & gut" by Jennifer Niederst Robbins)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

   

label

HTML 4.01 | HTML 5

<label> ... </label>

Used to provide additional information about controls. Each labelrefers to exactly one form element. The associated form element can be nested inside the label element. Otherwise, the attribute for is used with the ID of the associated form element.

Notes

In HTML 5, a label can contain the input element and use the for/id method.

Start/end tag

Required/required

Attributes

Core, internationalization, events, focus, global HTML 5 attributes

  • for="Text"

    Associates the label explicitly with a control. The attribute for contains the value of the id attribute of the form element for which the label is intended.

  • form="ID des übergeordneten Formulars"

    Associates the label explicitly with a specific parent form. With this method, the label does not necessarily have to be nested inside the corresponding form element.

Examples

A form in which the input element is nested inside the label element:

<label>Nachname: <input type="text" size="32"></label>

Using the for/id method to associate a label with the corresponding input form element:

<label for="Nachname">Nachname:</label>
<input type="text" id="Nachname" size="32">

 

> back to the alphabetical list of elements

   

 

 

 

back to top