* legend 要素型 (HTML, XHTML 1)

[1] [DFN[[CODE(HTMLe)[legnend]]]] は、 [CODE(HTMLe)[[[fieldset]]]]
に[RUBYB[題] [caption]]を割当てます。

[2] 仕様書:
- [[HTML 4]] ([[Web Forms 1.0]])
-- [CITE[17.10 Adding structure to forms: the [CODE(HTMLe)[FIELDSET]] and [CODE(HTMLe)[LEGEND]] elements]]
<IW:HTML4:"interact/forms.html#edef-LEGEND">
- [[Web Forms 2.0]]
-- [CSECTION@en[3.3. Changes to existing controls]]
<IW:WF2:"#changes">

[3]
:状態:[[W3C]] [[勧告]]
:[[名前空間URI]]:[CODE(URI)@en[[[http://www.w3.org/1999/xhtml]]]]
:[[局所名]]:[CODE(HTMLe)@en[[[legend]]]]
([Q[[RUBYB[銘] @en[legend]]]]より)
:[[開始タグ]]:必須
:[[終了タグ]]:必須
:[[内容模型]]:[CODE(SGML)[(%[[inline]])*]]
:出現できる文脈:[CODE(HTMLe)[[[fieldset]]]] の最初に1つ (必須)
:[[属性]]:
,属性名	,属性値	,既定値	,説明	,出典
,[CODE(HTMLa)[[[accesskey]]]]	,[CODE(SGML)[%[[Character]]]]	,	,	,[HTML 4]
,[CODE(HTMLa)[[[align]]]]	,	,	,配置	,[HTML 4] 非推奨
,[CODE(HTMLa)[[[class]]]]	,	,(なし)	,[[級]]	,"[HTML 4] %[[coreattrs]] ⊂ %[[attrs]], [XHTML 1] [[Core]] ⊂ [[Common]]"
,[CODE(HTMLa)[[[dir]]]]	,	,	,[[書字方向]]	,"[HTML 4] %[[i18n]] ⊂ %attrs, [XHTML 1] [[I18N]] ⊂ Common"
,[CODE(HTMLa)@en[[[form]]]],,,廃止,[DEL[[[Web Applications 1.0]]]]
,[CODE(HTMLa)[[[id]]]]	,[CODE(SGML)[[[ID]]]]	,(なし)	,一意識別子	,"[HTML 4] %coreattrs ⊂ %attrs, [XHTML 1] Core ⊂ Common"
,[CODE(HTMLa)[[[lang]]]]	,	,	,[[自然言語]]	,[HTML 4] %i18n ⊂ %attrs
,[CODE(HTMLa)[[[xml]]:lang]]	,	,	,自然言語	,[XHTML 1] I18N ⊂ Common
,[CODE(HTMLa)[[[onclick]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %[[events]] ⊂ %attrs, [XHTML 1] [[Events]] ⊂ Common"
,[CODE(HTMLa)[[[ondblclick]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onkeydown]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onkeypress]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onkeyup]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onmousedown]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onmousemove]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onmouseout]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onmouseover]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[onmouseup]]]]	,[CODE(SGML)[%[[Script]]]]	,(なし)	,	,"[HTML 4] %events ⊂ %attrs, [XHTML 1] Events ⊂ Common"
,[CODE(HTMLa)[[[style]]]]	,	,	,スタイル情報	,"[HTML 4] %coreattrs ⊂ %attrs, [XHTML 1] [[Style]] ⊂ Common"
,[CODE(HTMLa)[[[title]]]]	,	,	,注釈的題	,"[HTML 4] %coreattrs ⊂ %attrs, [XHTML 1] Core ⊂ Common"

** 内容モデル

[6]
[[Web Forms 2.0]] のメモ <IW:WF2:"#emptyElements">
によれば、 [[HTML 4]] では [CODE(HTMLe)@en[[[legend]]]]
は最低1[[文字]]の[[内容]]が必要だとされています。

これは [[HTML 4]] のどの部分が根拠でしょうか?

[7]
[[Web Forms 2.0]] では、 [CODE(HTMLe)@en[[[legend]]]]
[[要素]]は[[空]]に[['''して構いません''']]。
しかし、[[利用者]]の混乱を防ぐため、
[[空]]かつ可視な状態は避けるように[['''するべきです''']]。
[SRC@en[WF2 2.3]]

[[#comment]]


** アクセス可能性

[4] [CODE(HTMLe)[legend]] は非視覚レンダリングでのアクセス可能性を高めます 
[SRC[HTML 4 17.10]]。

[[#comment]]


** 関連

[5]
[CODE(HTMLe)@en[[[fieldset]]]] [[要素]]に対する
[CODE(HTMLe)@en[[[legend]]]] [[要素]]は、
- [[フォーム制御子]]に対する [CODE(HTMLe)@en[[[label]]]] [[要素]]
- [CODE(HTMLe)@en[[[table]]]] [[要素]]に対する
[CODE(HTMLe)@en[[[caption]]]] [[要素]]
- [CODE(HTMLe)@en[[[section]]]] 系[[要素]]に対する
[CODE(HTMLe)@en[[[h[VAR[n]]]]]] [[要素]]や
[CODE(HTMLe)@en[[[header]]]] [[要素]]
- [CODE(HTMLe)@en[[[html]]]] [[要素]]に対する
[CODE(HTMLe)@en[[[title]]]] [[要素]]
- [CODE(XMLe)@en[[VAR[xhtml2:]][[nl]]]] 系[[要素]]に対する
[CODE(XMLe)@en[[VAR[xhtml2:]][[label]]]] [[要素]]

と同じような関係にあります。

* 歴史

** HTML4 

[30] [CITE[Design Issues for HTML Forms]], [TIME[1999-02-04T17:41:10.000Z]], [TIME[2024-08-25T03:32:27.452Z]] <https://www.w3.org/TR/WD-forms-960308.html>



[FIG(data)[ [216] [[HTML要素概説]]

:[F[要素名]]:[CODE[is]]
:日付:[TIME[1995-03-08]]
:説明:
[TIME[1996-03-08]]付 [[W3C]] 文書で
[CODE[is]]
が提案されていた。
現在の [CODE[legend]]
に近いが、
ラベルと内容を区切るものだった。
:出典:
[REFS[

-
[CITE[Design Issues for HTML Forms]], 
[DATA(.author)[[[W3C]]]],
[DATA(.status)[[[Working Draft]]]],
[TIME(.published)[08-Mar-96][1996-03-08]],
[TIME[1999-02-04T17:41:10.000Z]], [TIME[2024-08-25T03:33:02.026Z]] <https://www.w3.org/TR/WD-forms-960308.html>

]REFS]

]FIG]

[32] 
[[Cougar]] では [CODE[caption]] が使われていました。 [CITE[HTML 4.0]]
になって
[CODE[legend]] になりました。
[SEE[ [[fieldset]] ]]

** HTML5


[31] [CITE@en[the legend element (if anyone has a better idea of how to classify th…]], [[Hixie]], [TIME[2006-11-26 15:29:44 +09:00]], [TIME[2024-09-01T12:25:41.000Z]] <https://github.com/whatwg/html/commit/967ec89c0f160d612c30aa584f271674f7089f2f#diff-41cf6794ba4200b839c53531555f0f3998df4cbb01a4d5cb0b94e3ca5e23947d>

[FIG(data)[ [48] [[HTML要素概説]]

:[F[要素名]]:[CODE[legend]]
:日付:[TIME[2006-11-26]]
:説明:
[TIME[2006-11-26]]、
[CITE[HTML5]]
は
[CODE[legend]]
を定義した。
現行仕様である。
:出典:
[REFS[

- [CITE[HTML5 r363]],
[DATA(.author)[[[Hixie]]]], 
[TIME(.published)[2006-11-26 15:29:44 +09:00]], [TIME[2024-09-01T12:25:41.000Z]] <https://github.com/whatwg/html/commit/967ec89c0f160d612c30aa584f271674f7089f2f>


]REFS]
:参照:[CODE[summary]]
:参照:[CODE[figcaption]]
:参照:[CODE[dt]]

]FIG]





[77] [CITE@en[(X)HTML5 Tracking]]
([TIME[2009-10-12 19:07:38 +09:00]] 版)
<http://html5.org/tools/web-apps-tracker?from=4114&to=4115>

[78] [CITE[IRC logs: freenode / #whatwg / 20090903]]
([TIME[2009-10-17 12:08:54 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20090903#l-31>

[79] [CITE[IRC logs: freenode / #whatwg / 20100211]]
([TIME[2010-02-13 15:54:31 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20100211#l-145>

[80] [CITE@en[Web Applications 1.0 r5504     make the legend rendering requirements only apply when they make senseFixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10547]]
( ([TIME[2010-09-26 09:52:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5503&to=5504>

[81] [CITE@en[Web Applications 1.0 r7987     Make <legend> styles match reality.]]
( ([TIME[2013-06-19 07:37:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7986&to=7987>

[8] [CITE@en[Editorial: Cross-reference DOM "child" where appropriate in rendering]]
([[zcorpan]]著, [TIME[2016-09-20 20:16:41 +09:00]])
<https://github.com/whatwg/html/commit/e8c91c05edc8d6cdb33fdd5452e052359d40490b>

[9] [CITE@en[The "rendered legend" creates a new block formatting context]]
([[zcorpan]]著, [TIME[2017-06-07 21:30:20 +09:00]])
<https://github.com/whatwg/html/commit/7ef15998b3a968f0fd7eb30dc126427e13349dbe>

[10] [CITE@en[Refer to a fieldset's legend as a caption to reduce confusion]]
([[zcorpan]]著, [TIME[2018-08-21 19:16:49 +09:00]])
<https://github.com/whatwg/html/commit/169413911523380c64d5ec66a60bed1992bdc7ca>

[11] [CITE@en[Name of <fieldset> group given by <legend> and <fieldset name=""> confusable · Issue #3702 · whatwg/html]]
([TIME[2018-09-04 16:25:54 +09:00]])
<https://github.com/whatwg/html/issues/3702>

[12] [CITE@en[Refer to a fieldset's legend as a caption to reduce confusion by zcorpan · Pull Request #3951 · whatwg/html]]
([TIME[2018-09-04 16:26:32 +09:00]])
<https://github.com/whatwg/html/pull/3951>

[13] [CITE@en[Tweak how accesskey on legend works]]
([[zcorpan]]著, [TIME[2018-09-07 06:25:22 +09:00]])
<https://github.com/whatwg/html/commit/aa374be03beebf25ed33022846c2d03d3ea03484>

[14] [CITE@en[focus() on a non-focusable legend delegates focus in WebKit/Chromium · Issue #3950 · whatwg/html]]
([TIME[2018-10-14 17:52:33 +09:00]])
<https://github.com/whatwg/html/issues/3950>

[15] [CITE@en[Tweak how accesskey on legend works by zcorpan · Pull Request #3987 · whatwg/html]]
([TIME[2018-10-14 17:53:06 +09:00]])
<https://github.com/whatwg/html/pull/3987>

[16] [CITE@en[Clarify which legend/figcaption/caption element to use (#146)]]
([[@zcorpan]]著, [TIME[2018-09-08 05:46:12 +09:00]])
<https://github.com/w3c/html-aam/commit/f311fe023964e1536e2f7d389aa02da6a824a741>

[17] [CITE@en[Unclear which legend element to be used as accessible name for fieldset · Issue #145 · w3c/html-aam]]
([TIME[2018-10-17 13:00:43 +09:00]])
<https://github.com/w3c/html-aam/issues/145>

[18] [CITE@en[Clarify which legend/figcaption/caption element to use by zcorpan · Pull Request #146 · w3c/html-aam]]
([TIME[2018-10-17 13:02:19 +09:00]])
<https://github.com/w3c/html-aam/pull/146>

[19] [CITE@en[Revamp how fieldset and legend rendering is defined]]
([[zcorpan]]著, [TIME[2018-09-20 03:04:40 +09:00]])
<https://github.com/whatwg/html/commit/6fbb7ff8fbe1c76506145ba8ffce690224be66e0>

[20] [CITE@en[Define whether fieldset's legend should mask border-image · Issue #3930 · whatwg/html]]
([TIME[2018-10-19 17:11:19 +09:00]])
<https://github.com/whatwg/html/issues/3930>

[21] [CITE@en[Define how margin-top on fieldset's legend works · Issue #3929 · whatwg/html]]
([TIME[2018-10-19 17:11:42 +09:00]])
<https://github.com/whatwg/html/issues/3929>

[22] [CITE@en[fieldset's "rendered legend" should force used value of display to block · Issue #3927 · whatwg/html]]
([TIME[2018-10-19 17:12:11 +09:00]])
<https://github.com/whatwg/html/issues/3927>

[23] [CITE@en[fieldset's legend should probably inherit alignment · Issue #3913 · whatwg/html]]
([TIME[2018-10-19 17:12:23 +09:00]])
<https://github.com/whatwg/html/issues/3913>

[24] [CITE@en[The definition of "rendered legend" should use the box tree, or at least the flat tree. · Issue #3331 · whatwg/html]]
([TIME[2018-10-19 17:13:04 +09:00]])
<https://github.com/whatwg/html/issues/3331>

[25] [CITE@en[Unresolvable dependencies in determining the rendered fieldset legend · Issue #2756 · whatwg/html]]
([TIME[2018-10-19 17:13:24 +09:00]])
<https://github.com/whatwg/html/issues/2756>

[26] [CITE@en[Revamp how fieldset and legend rendering is defined by zcorpan · Pull Request #3934 · whatwg/html]]
([TIME[2018-10-19 17:13:59 +09:00]])
<https://github.com/whatwg/html/pull/3934>

[27] [CITE@en[Refer to a fieldset's legend as a caption to reduce confusion]]
([[zcorpan]]著, [TIME[2018-08-21 19:16:49 +09:00]])
<https://github.com/whatwg/html/commit/169413911523380c64d5ec66a60bed1992bdc7ca>

[28] [CITE@en[Name of <fieldset> group given by <legend> and <fieldset name=""> confusable · Issue #3702 · whatwg/html]]
([TIME[2019-03-04 16:40:41 +09:00]])
<https://github.com/whatwg/html/issues/3702>

[29] [CITE@en[Refer to a fieldset's legend as a caption to reduce confusion by zcorpan · Pull Request #3951 · whatwg/html]]
([TIME[2019-03-04 16:41:04 +09:00]])
<https://github.com/whatwg/html/pull/3951>