<legend>: Das Field Set Legend-Element

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Das <legend> HTML-Element stellt eine Beschriftung für den Inhalt seines übergeordneten <fieldset> dar.

Probieren Sie es aus

<fieldset>
  <legend>Choose your favorite monster</legend>

  <input type="radio" id="kraken" name="monster" value="K" />
  <label for="kraken">Kraken</label><br />

  <input type="radio" id="sasquatch" name="monster" value="S" />
  <label for="sasquatch">Sasquatch</label><br />

  <input type="radio" id="mothman" name="monster" value="M" />
  <label for="mothman">Mothman</label>
</fieldset>
legend {
  background-color: #000;
  color: #fff;
  padding: 3px 6px;
}

input {
  margin: 0.4rem;
}

Attribute

Dieses Element umfasst nur die globalen Attribute.

Beispiele

Siehe <form> für Beispiele zu <legend>.

Technische Zusammenfassung

Inhaltskategorien Keine.
Erlaubter Inhalt Phrasierungsinhalt und Überschriften (h1–h6 Elemente).
Tag-Auslassung Keine, sowohl der Start- als auch der Endtag sind obligatorisch.
Erlaubte Eltern Ein <fieldset>, dessen erstes Kind dieses <legend>-Element ist
Implizite ARIA-Rolle Keine entsprechende Rolle
Erlaubte ARIA-Rollen Keine role erlaubt
DOM-Schnittstelle [`HTMLLegendElement`](/de/docs/Web/API/HTMLLegendElement)

Spezifikationen

Specification
HTML
# the-legend-element

Browser-Kompatibilität

BCD tables only load in the browser

Siehe auch