-
Notifications
You must be signed in to change notification settings - Fork 4
/
407.txt
156 lines (121 loc) · 7.45 KB
/
407.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
[2] [DFN[void [RUBYB[要素]@en[element]]]]は、[[構文]]としての [[HTML]] において、
[[終了タグ]]が''存在せず'' (存在できず) 常に[[開始タグ]]のみで記述される[[要素]]のことです。
;; かつては「[[空要素]]」とも呼ばれていました (>>3)。
* 仕様書
[REFS[
- [6] '''[CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-06-05 00:28:03 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#void-elements>'''
- [9] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-06-05 00:28:03 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#html-fragment-serialization-algorithm>
]REFS]
* 一覧
[7] [[HTML]] の構文定義上[[void要素]]とされているのは次の[[要素]]です [SRC[>>6]]。
[FIG(short list)[
- [CODE(HTMLe)@en[[[area]]]]
- [CODE(HTMLe)@en[[[base]]]]
- [CODE(HTMLe)@en[[[br]]]]
- [CODE(HTMLe)@en[[[col]]]]
- [CODE(HTMLe)@en[[[embed]]]]
- [CODE(HTMLe)@en[[[hr]]]]
- [CODE(HTMLe)@en[[[img]]]]
- [CODE(HTMLe)@en[[[input]]]]
- [CODE(HTMLe)@en[[[link]]]]
- [CODE(HTMLe)@en[[[meta]]]]
- [CODE(HTMLe)@en[[[param]]]]
- [CODE(HTMLe)@en[[[source]]]]
- [CODE(HTMLe)@en[[[track]]]]
- [CODE(HTMLe)@en[[[wbr]]]]
[HISTORY[
- [CODE(HTMLe)@en[menuitem]]
]HISTORY]
]FIG]
[8] これらは現在の [[HTML]] に含まれる[[要素]]ですが、実際には、[[不適合]]であって[[著者]]は使ってはいけないとされながらも後方互換性のために
[[HTML構文解析器]]や[[直列化器]]は実装しなければならないとされている[[void要素]]
([DFN[serializes as void]]) があります。
これには次の[[要素]]が含まれます [SRC[>>9]]。
[FIG(short list)[
- [CODE(HTMLe)@en[[[basefont]]]]
- [CODE(HTMLe)@en[[[bgsound]]]]
- [CODE(HTMLe)@en[[[frame]]]]
- [CODE(HTMLe)@en[keygen]]
]FIG]
[10] これに加えて、形式的には[[void要素]]であるものの、[[構文解析器]]で展開される「[[マクロ]]」
的な[[タグ]]であり、[[直列化器]]も[[void要素]]のようには扱わないものが2種類あります。
仕様書の[[直列化器]]の定義では参考までに[[注釈]]として言及がありました [SRC[>>9, >>27]]。
[FIG(short list)[
- [CODE(HTMLe)@en[[[image]]]]
[HISTORY[
- [CODE(HTMLe)@en[[[isindex]]]]
]HISTORY]
]FIG]
[11] 歴史的にはこれら以外にも一時[[void要素]]として実装されていたものの現在に残っていないもの、
一部の実装にのみ残っているもの、定義が改められて現在では[[void要素]]でないもの、
提案されたものの実装されなかったものなどがあります。
[EG[
[24] かつて [[IE]] は [CODE(HTMLe)@en[nextid]] [[要素]]を [[void要素]]として[[構文解析]]していました。
]EG]
[EG[
[14] 例えば [CODE(HTMLe)@en[[[spacer]]]] [[要素]]はかつて [[Netscape Navigator]]
が実装しており、最近まで [[Gecko]] の[[構文解析器]]も [[void要素]]として扱っていましたが、
現在の [[HTML]] 仕様上は [[void要素]]ではありません。
]EG]
[EG[
[15] 例えば [CODE(HTMLe)@en[[[canvas]]]] [[要素]]はかつて [[void要素]]として実装されていましたが、
現在では通常の[[要素]]として定義・実装されています。
]EG]
[EG[
[17] [[Opera]] は [[HTML5]] の [CODE(HTMLe)@en[[[event-source]]]] [[要素]]を実装していましたが、
現在では仕様からも実装からも削除されています。
]EG]
[EG[
[18] [[HTML5]] は [CODE(HTMLe)@en[[[command]]]] [[要素]]を [[void要素]]として定義しており、
一時[[構文解析器]]で実装もされていましたが、[[要素]]としては実装されておらず、
その後仕様からも削除されました。実装からも現在は削除されています。
]EG]
[12] [[HTML文書]]には [[SVG]] や [[MathML]] の[[要素]]を含めることもできますが、
その場合、[[HTML]] の [[void要素]]と同じ[[タグ名]]であったとしても、[[void要素]]とはならず、
通常の[[要素]]として構文解析・直列化されます。
;; [13] [[HTML文書]]中の [[SVG]] や [[MathML]] の[[要素]]や [[XML文書]]中の[[要素]]は、
[CODE(HTML)@en[<foo />]] のように[[空要素]]構文を使って簡略化して表記することができます。
これは [[void要素]]でも認められていますが、この構文を使っているからといって
[[void要素]]であるとは限りません。
[19] 現在の [[void要素]]の一覧は
[REFS[
- [20] [CITE[data-web-defs/doc/elements.txt at master · manakai/data-web-defs]] ([TIME[2014-07-26 11:44:37 +09:00]] 版) <https://github.com/manakai/data-web-defs/blob/master/doc/elements.txt>
]REFS]
... に [[JSON]] 形式で用意されています。
* 関連
[3] 歴史的には [[void要素]]は[[空要素]]や[[強制空要素]]とも呼ばれてきましたが、
[[内容モデル]]における[[空要素]]と区別するため、[[Web Applications 1.0]]
で新たに「[[void要素]]」という呼称が導入されました。
[21] [[void要素]]の[[内容モデル]]は[[空]]となっています。しかし、
[[内容モデル]]が[[空]]の[[要素]]がすべて[[void要素]]であるわけではありません。
[22] また、 [[void要素]]は [[HTML構文]]における概念で、 [[XML]] ([[XHTML]]) や [[DOM]]
には存在しません。 [[void要素]]であっても、 [[XML]] や [[DOM]] では[[子供]]を持つことができます。
* 歴史
[1] [[HTML]] mode では、 [[Gecko]] は [CODE(HTML)[<br></br>]] を [CODE(HTML)[<br><br>]] と解釈するようです。それでいて [CODE(HTML)[<input [INS[...]]></input>]] は [CODE(HTML)[<input/>]] と意図したように解釈してくれます。
[4] [CITE@en[XSLT 2.0 and XQuery 1.0 Serialization (Second Edition)]]
( ([TIME[2010-12-17 00:08:20 +09:00]] 版))
<http://www.w3.org/TR/2010/REC-xslt-xquery-serialization-20101214/#XHTMLEMPTY>
[5] [CITE@en[XSLT 2.0 and XQuery 1.0 Serialization (Second Edition)]]
( ([TIME[2010-12-17 00:08:20 +09:00]] 版))
<http://www.w3.org/TR/2010/REC-xslt-xquery-serialization-20101214/#XML-ISLAND>
[16] [CITE@en[XSLT and XQuery Serialization 3.0]]
( ([TIME[2014-04-07 23:19:15 +09:00]] 版))
<http://www.w3.org/TR/xslt-xquery-serialization-3/#XHTMLVOID>
[23] [CITE@en[Fix #234: Change <menuitem> from void to like-<option> · whatwg/html@5e49a20]]
([TIME[2016-04-16 20:59:32 +09:00]] 版)
<https://github.com/whatwg/html/commit/5e49a20874fabef620bf7ea0be7534c73fbd58c4>
[25] [CITE@en[Remove <keygen>]]
([[domenic]]著, [TIME[2017-01-14 07:03:02 +09:00]])
<https://github.com/whatwg/html/commit/5baa38720f6e83c94a50018c4565808ad548d69c>
[26] [CITE@en[XSLT and XQuery Serialization 3.1]]
([TIME[2017-03-20 12:35:18 +09:00]])
<https://www.w3.org/TR/2017/REC-xslt-xquery-serialization-31-20170321/#XHTMLVOID>
[27] [CITE@en[Serialize the children of void elements as the empty string]]
([[Zirro]]著, [TIME[2018-12-20 05:52:23 +09:00]])
<https://github.com/whatwg/html/commit/d36d3eb0e2164d3bdec168f047f15b7925bd5f83>
[28] [CITE@en[Should the innerHTML of void elements include child nodes? · Issue #4220 · whatwg/html]]
([TIME[2019-06-03 11:55:49 +09:00]])
<https://github.com/whatwg/html/issues/4220>
[29] [CITE@en[Serialize the children of void elements as the empty string by Zirro · Pull Request #4238 · whatwg/html]]
([TIME[2019-06-03 11:56:18 +09:00]])
<https://github.com/whatwg/html/pull/4238>