Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

<legend>: The Field Set Legend element

BaselineWidely available

The<legend>HTML element represents a caption for the content of its parent<fieldset>.

Incustomizable<select> elements, the<legend> element is allowed as a child of<optgroup>, to provide a label that is easy to target and style. This replaces any text set in the<optgroup> element'slabel attribute, and it has the same semantics.

Try it

<fieldset>  <legend>Choose your favorite monster</legend>  <input type="radio" name="monster" value="K" />  <label for="kraken">Kraken</label><br />  <input type="radio" name="monster" value="S" />  <label for="sasquatch">Sasquatch</label><br />  <input type="radio" name="monster" value="M" />  <label for="mothman">Mothman</label></fieldset>
legend {  background-color: #000;  color: #fff;  padding: 3px 6px;}input {  margin: 0.4rem;}

Attributes

This element only includes theglobal attributes.

Examples

See<form> for examples on<legend>.

Technical summary

Content categoriesNone.
Permitted contentPhrasing content andheadings (h1–h6 elements).
Tag omissionNone, both the starting and ending tag are mandatory.
Permitted parents A<fieldset> whose first child is this<legend> element. Incustomizable select elements, a<legend> element is permitted as a child of<optgroup> .
Implicit ARIA roleNo corresponding role
Permitted ARIA rolesNorole permitted
DOM interfaceHTMLLegendElement

Specifications

Specification
HTML
# the-legend-element

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp