Annotation of html5/spec/interactive-elements.html, revision 1.1039
1.866 mike 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.1037 mike 2: <!DOCTYPE html>
1.1029 mike 3: <html lang="en-US-x-Hixie" class="split chapter"><head><title>4.11 Interactive elements — HTML5 </title><style type="text/css">
1.1 mike 4: pre { margin-left: 2em; white-space: pre-wrap; }
5: h2 { margin: 3em 0 1em 0; }
6: h3 { margin: 2.5em 0 1em 0; }
7: h4 { margin: 2.5em 0 0.75em 0; }
8: h5, h6 { margin: 2.5em 0 1em; }
9: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
10: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
11: p { margin: 1em 0; }
12: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
13: dl, dd { margin-top: 0; margin-bottom: 0; }
14: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
15: dt + dt { margin-top: 0; }
16: dd dt { margin-top: 0.25em; margin-bottom: 0; }
17: dd p { margin-top: 0; }
18: dd dl + p { margin-top: 1em; }
19: dd table + p { margin-top: 1em; }
20: p + * > li, dd li { margin: 1em 0; }
21: dt, dfn { font-weight: bold; font-style: normal; }
22: dt dfn { font-style: italic; }
23: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
24: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
25: pre em { font-weight: bolder; font-style: normal; }
26: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
27: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
28: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
1.974 mike 29: table thead, table tbody { border-bottom: solid; }
1.1 mike 30: table tbody th:first-child { border-left: solid; }
1.469 mike 31: table tbody th { text-align: left; }
1.1 mike 32: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
33: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
34:
35: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
36: .matrix, .matrix td { border: none; text-align: right; }
37: .matrix { margin-left: 2em; }
38: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
39: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
40: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
41:
42: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
43: img.extra { float: right; }
44: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
45: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
46: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
47: pre.css:first-line { color: #AAAA50; }
1.834 mike 48: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1 mike 49: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
50: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
51: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
52: dl.domintro dd p { margin: 0.5em 0; }
53: dl.switch { padding-left: 2em; }
54: dl.switch > dt { text-indent: -1.5em; }
55: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
56: dl.triple { padding: 0 0 0 1em; }
57: dl.triple dt, dl.triple dd { margin: 0; display: inline }
58: dl.triple dt:after { content: ':'; }
59: dl.triple dd:after { content: '\A'; white-space: pre; }
60: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
61: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
62: a .diff-new { border-bottom: 1px blue solid; }
63:
64: h2 { page-break-before: always; }
65: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
66: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
67:
1.1012 mike 68: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
69: li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
1.1 mike 70:
71: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
72: div.head p { margin: 0; }
73: div.head h1 { margin: 0; }
74: div.head .logo { float: right; margin: 0 1em; }
75: div.head .logo img { border: none } /* remove border from top image */
76: div.head dl { margin: 1em 0; }
1.665 mike 77: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1 mike 78:
79: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
80: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
81: body > .toc > li > * { margin-bottom: 0.5em; }
82: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
83: .toc, .toc li { list-style: none; }
84:
85: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
86: .brief li { margin: 0; padding: 0; }
87: .brief li p { margin: 0; padding: 0; }
88:
89: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
90: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
91: .category-list li { display: inline; }
92: .category-list li:not(:last-child)::after { content: ', '; }
93: .category-list li > span, .category-list li > a { text-transform: lowercase; }
94: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
95:
96: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
97: .XXX > :first-child { margin-top: 0; }
98: p .XXX { line-height: 3em; }
1.153 mike 99: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
100: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
101: .annotation :link, .annotation :visited { color: inherit; }
102: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
103: .annotation span { border: none ! important; }
1.1 mike 104: .note { color: green; background: transparent; font-family: sans-serif; }
105: .warning { color: red; background: transparent; }
106: .note, .warning { font-weight: bolder; font-style: italic; }
107: p.note, div.note { padding: 0.5em 2em; }
108: span.note { padding: 0 2em; }
109: .note p:first-child, .warning p:first-child { margin-top: 0; }
110: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
111: .warning:before { font-style: normal; }
112: p.note:before { content: 'Note: '; }
113: p.warning:before { content: '\26A0 Warning! '; }
114:
115: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
116: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
117: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
1.996 mike 118: .bookkeeping dt { margin: 0.5em 2em 0; }
119: .bookkeeping dd { margin: 0 3em 0.5em; }
1.1 mike 120:
121: h4 { position: relative; z-index: 3; }
122: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
123: .element {
124: background: #EEEEFF;
125: color: black;
126: margin: 0 0 1em 0.15em;
127: padding: 0 1em 0.25em 0.75em;
128: border-left: solid #9999FF 0.25em;
129: position: relative;
130: z-index: 1;
131: }
132: .element:before {
133: position: absolute;
134: z-index: 2;
135: top: 0;
136: left: -1.15em;
137: height: 2em;
138: width: 0.9em;
139: background: #EEEEFF;
140: content: ' ';
141: border-style: none none solid solid;
142: border-color: #9999FF;
143: border-width: 0.25em;
144: }
145:
1.143 mike 146: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
147: td > .example:only-child { margin: 0 0 0 0.1em; }
1.1 mike 148:
149: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
150: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
151: ul.domTree li li { list-style: none; }
152: ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
153: ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
154: ul.domTree span { font-style: italic; font-family: serif; }
155: ul.domTree .t1 code { color: purple; font-weight: bold; }
156: ul.domTree .t2 { font-style: normal; font-family: monospace; }
157: ul.domTree .t2 .name { color: black; font-weight: bold; }
158: ul.domTree .t2 .value { color: blue; font-weight: normal; }
159: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
160: ul.domTree .t7 code, .domTree .t8 code { color: green; }
161: ul.domTree .t10 code { color: teal; }
162:
1.730 mike 163: body.dfnEnabled dfn { cursor: pointer; }
164: .dfnPanel {
165: display: inline;
166: position: absolute;
167: z-index: 10;
168: height: auto;
169: width: auto;
170: padding: 0.5em 0.75em;
171: font: small sans-serif, Droid Sans Fallback;
172: background: #DDDDDD;
173: color: black;
174: border: outset 0.2em;
175: }
176: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
177: .dfnPanel :link, .dfnPanel :visited { color: black; }
178: .dfnPanel p { font-weight: bolder; }
179: .dfnPanel * + p { margin-top: 0.25em; }
180: .dfnPanel li { list-style-position: inside; }
181:
1.665 mike 182: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
183: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
184: #configUI p label { display: block; }
185: #configUI #updateUI, #configUI .loginUI { text-align: center; }
186: #configUI input[type=button] { display: block; margin: auto; }
1.995 mike 187:
1.1018 mike 188: fieldset { margin: 1em; padding: 0.5em 1em; }
189: fieldset > legend + * { margin-top: 0; }
1.1009 mike 190: fieldset > :last-child { margin-bottom: 0; }
1.1018 mike 191: fieldset p { margin: 0.5em 0; }
192:
1.1038 mike 193: </style><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css"><style type="text/css">
1.261 mike 194:
1.286 mike 195: .applies thead th > * { display: block; }
196: .applies thead code { display: block; }
197: .applies tbody th { whitespace: nowrap; }
198: .applies td { text-align: center; }
199: .applies .yes { background: yellow; }
200:
1.997 mike 201: .matrix, .matrix td { border: hidden; text-align: right; }
1.261 mike 202: .matrix { margin-left: 2em; }
203:
204: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
205: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
206: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
207:
1.1003 mike 208: td.eg { border-width: thin; text-align: center; }
209:
1.261 mike 210: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
211: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
212: #table-example-1 caption { padding-bottom: 0.5em; }
213: #table-example-1 thead, #table-example-1 tbody { border: none; }
214: #table-example-1 th, #table-example-1 td { border: solid thin; }
215: #table-example-1 th { font-weight: normal; }
216: #table-example-1 td { border-style: none solid; vertical-align: top; }
217: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
218: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
219: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
220: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
221: #table-example-1 tbody td:first-child::after { content: leader(". "); }
222: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
223: #table-example-1 tbody td:first-child + td { width: 10em; }
224: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
225: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
226:
227: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
228: .apple-table-examples * { font-family: "Times", serif; }
229: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
230: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
231: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
232: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
233: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
234: .apple-table-examples td { text-align: right; vertical-align: top; }
235: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
236: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
237: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
238: .apple-table-examples sup { line-height: 0; }
239:
1.718 mike 240: .details-example img { vertical-align: top; }
241:
1.1023 mike 242: #base64-table {
243: white-space: nowrap;
244: font-size: 0.6em;
245: column-width: 6em;
246: column-count: 5;
247: column-gap: 1em;
248: -moz-column-width: 6em;
249: -moz-column-count: 5;
250: -moz-column-gap: 1em;
251: -webkit-column-width: 6em;
252: -webkit-column-count: 5;
253: -webkit-column-gap: 1em;
254: }
255: #base64-table thead { display: none; }
256: #base64-table * { border: none; }
257: #base64-table tbody td:first-child:after { content: ':'; }
258: #base64-table tbody td:last-child { text-align: right; }
259:
1.875 mike 260: #named-character-references-table {
1.1006 mike 261: white-space: nowrap;
1.875 mike 262: font-size: 0.6em;
1.1006 mike 263: column-width: 30em;
1.875 mike 264: column-gap: 1em;
1.1006 mike 265: -moz-column-width: 30em;
1.875 mike 266: -moz-column-gap: 1em;
1.1006 mike 267: -webkit-column-width: 30em;
1.875 mike 268: -webkit-column-gap: 1em;
269: }
1.1006 mike 270: #named-character-references-table > table > tbody > tr > td:first-child + td,
1.875 mike 271: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
272: #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
1.1006 mike 273: #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
1.875 mike 274:
1.988 mike 275: .glyph.control { color: red; }
276:
1.990 mike 277: @font-face {
278: font-family: 'Essays1743';
279: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
280: }
281: @font-face {
282: font-family: 'Essays1743';
283: font-weight: bold;
284: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
285: }
286: @font-face {
287: font-family: 'Essays1743';
288: font-style: italic;
289: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
290: }
291: @font-face {
292: font-family: 'Essays1743';
293: font-style: italic;
294: font-weight: bold;
295: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
296: }
297:
1.866 mike 298: </style><style type="text/css">
1.874 mike 299: .domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
1.1037 mike 300: </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.1028 mike 301: function getCookie(name) {
302: var params = location.search.substr(1).split("&");
303: for (var index = 0; index < params.length; index++) {
304: if (params[index] == name)
305: return "1";
306: var data = params[index].split("=");
307: if (data[0] == name)
308: return unescape(data[1]);
309: }
310: var cookies = document.cookie.split("; ");
311: for (var index = 0; index < cookies.length; index++) {
312: var data = cookies[index].split("=");
313: if (data[0] == name)
314: return unescape(data[1]);
315: }
316: return null;
317: }
318: </script>
1.987 mike 319: <script src="link-fixup.js"></script>
1.1020 mike 320: <link href="style.css" rel="stylesheet"><link href="association-of-controls-and-forms.html" title="4.10.18 Association of controls and forms" rel="prev">
1.2 mike 321: <link href="spec.html#contents" title="Table of contents" rel="index">
1.1011 mike 322: <link href="commands.html" title="4.11.5 Commands" rel="next">
1.1034 mike 323: </head><body><div class="head" id="head">
1.1 mike 324: <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.989 mike 325:
1.177 mike 326: <h1>HTML5</h1>
1.868 mike 327: </div><div>
1.1020 mike 328: <a href="association-of-controls-and-forms.html" class="prev">4.10.18 Association of controls and forms</a> –
1.2 mike 329: <a href="spec.html#contents">Table of contents</a> –
1.1020 mike 330: <a href="commands.html" class="next">4.11.5 Commands</a>
1.1011 mike 331: <ol class="toc"><li><ol><li><a href="interactive-elements.html#interactive-elements"><span class="secno">4.11 </span>Interactive elements</a>
1.1030 mike 332: <ol><li><a href="interactive-elements.html#the-details-element"><span class="secno">4.11.1 </span>The <code>details</code> element</a></li><li><a href="interactive-elements.html#the-summary-element"><span class="secno">4.11.2 </span>The <code>summary</code> element</a></li><li><a href="interactive-elements.html#the-command-element"><span class="secno">4.11.3 </span>The <code>command</code> element</a></li><li><a href="interactive-elements.html#the-menu-element"><span class="secno">4.11.4 </span>The <code>menu</code> element</a>
1.1011 mike 333: <ol><li><a href="interactive-elements.html#menus-intro"><span class="secno">4.11.4.1 </span>Introduction</a></li><li><a href="interactive-elements.html#building-menus-and-toolbars"><span class="secno">4.11.4.2 </span>Building menus and toolbars</a></li><li><a href="interactive-elements.html#context-menus"><span class="secno">4.11.4.3 </span>Context menus</a></li><li><a href="interactive-elements.html#toolbars"><span class="secno">4.11.4.4 </span>Toolbars</a></li></ol></li></ol></li></ol></li></ol></div>
1.1 mike 334:
1.1011 mike 335: <h3 id="interactive-elements"><span class="secno">4.11 </span>Interactive elements</h3><h4 id="the-details-element"><span class="secno">4.11.1 </span>The <dfn><code>details</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
1.987 mike 336: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
337: <dd><a href="sections.html#sectioning-root">Sectioning root</a>.</dd>
338: <dd><a href="content-models.html#interactive-content">Interactive content</a>.</dd>
1.1002 mike 339: <dt>Contexts in which this element can be used:</dt>
1.987 mike 340: <dd>Where <a href="content-models.html#flow-content">flow content</a> is expected.</dd>
1.1 mike 341: <dt>Content model:</dt>
1.987 mike 342: <dd>One <code><a href="#the-summary-element">summary</a></code> element followed by <a href="content-models.html#flow-content">flow content</a>.</dd>
1.1 mike 343: <dt>Content attributes:</dt>
1.987 mike 344: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 345: <dd><code title="attr-details-open"><a href="#attr-details-open">open</a></code></dd>
346: <dt>DOM interface:</dt>
347: <dd>
1.987 mike 348: <pre class="idl">interface <dfn id="htmldetailselement">HTMLDetailsElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 349: attribute boolean <a href="#dom-details-open" title="dom-details-open">open</a>;
350: };</pre>
351: </dd>
1.987 mike 352: </dl><p>The <code><a href="#the-details-element">details</a></code> element <a href="rendering.html#represents">represents</a> a
1.307 mike 353: disclosure widget from which the user can obtain additional
354: information or controls.</p><p class="note">The <code><a href="#the-details-element">details</a></code> element is not appropriate
1.987 mike 355: for footnotes. Please see <a href="links.html#footnotes">the section on
1.729 mike 356: footnotes</a> for details on how to mark up footnotes.</p><p>The <span class="impl">first</span> <code><a href="#the-summary-element">summary</a></code> element
1.987 mike 357: child of the element, if any, <a href="rendering.html#represents">represents</a> the summary or
1.729 mike 358: legend of the details. <span class="impl">If there is no child
359: <code><a href="#the-summary-element">summary</a></code> element, the user agent should provide its own
1.1038 mike 360: legend (e.g. "Details").</span></p><p>The rest of the element's contents <a href="rendering.html#represents">represents</a> the
361: additional information or controls.</p><p>The <dfn id="attr-details-open" title="attr-details-open"><code>open</code></dfn>
1.987 mike 362: content attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a>. If present,
1.1038 mike 363: it indicates that both the summary and the additional information is
364: to be shown to the user. If the attribute is absent, only the
365: summary is to be shown.</p><div class="impl">
1.1 mike 366:
1.1033 mike 367: <p>When the element is created, if the attribute is absent, the
1.1038 mike 368: additional information should be hidden; if the attribute is absent,
369: that information should be shown. Subsequently, if the attribute is
370: removed, then the information should be hidden; if the attribute is
371: added, the information should be shown.</p>
372:
373: <p>The user agent should allow the user to request that the
374: additional information be shown or hidden. To honor a request for
375: the details to be shown, the user agent must set the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> attribute on the element to
1.1 mike 376: the value <code title="">open</code>. To honor a request for the
1.1038 mike 377: information to be hidden, the user agent must remove the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> attribute from the
1.1 mike 378: element.</p>
379:
1.1024 mike 380: <p>The <dfn id="dom-details-open" title="dom-details-open"><code>open</code></dfn> IDL
1.987 mike 381: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> content attribute.</p>
1.1 mike 382:
1.271 mike 383: </div><div class="example">
384:
385: <p>The following example shows the <code><a href="#the-details-element">details</a></code> element
386: being used to hide technical details in a progress report.</p>
387:
388: <pre><section class="progress window">
389: <h1>Copying "Really Achieving Your Childhood Dreams"</h1>
390: <details>
1.876 mike 391: <summary>Copying... <progress max="375505392" value="97543282"></progress> 25%</summary>
1.729 mike 392: <dl>
393: <dt>Transfer rate:</dt> <dd>452KB/s</dd>
394: <dt>Local filename:</dt> <dd>/home/rpausch/raycd.m4v</dd>
395: <dt>Remote filename:</dt> <dd>/var/www/lectures/raycd.m4v</dd>
396: <dt>Duration:</dt> <dd>01:16:27</dd>
397: <dt>Color profile:</dt> <dd>SD (6-1-6)</dd>
398: <dt>Dimensions:</dt> <dd>320×240</dd>
399: </dl>
1.271 mike 400: </details>
401: </section></pre>
402:
1.718 mike 403: </div><div class="example">
404:
405: <p>The following shows how a <code><a href="#the-details-element">details</a></code> element can be
406: used to hide some controls by default:</p>
407:
408: <pre><details>
1.1004 mike 409: <summary><label for=fn>Name & Extension:</label></summary>
410: <p><input type=text id=fn name=fn value="Pillar Magazine.pdf">
1.729 mike 411: <p><label><input type=checkbox name=ext checked> Hide extension</label>
1.718 mike 412: </details></pre>
413:
1.1031 mike 414: <p>One could use this in conjunction with other <code><a href="#the-details-element">details</a></code>
1.718 mike 415: in a list to allow the user to collapse a set of fields down to a
416: small set of headings, with the ability to open each one.</p>
417:
1.1037 mike 418: <p class="details-example"><img alt="" height="611" src="http://dev.w3.org/html5/spec/images/sample-details-1.png" width="345"><img alt="" height="666" src="http://dev.w3.org/html5/spec/images/sample-details-2.png" width="345"></p>
1.718 mike 419:
1.729 mike 420: <p>In these examples, the summary really just summarises what the
421: controls can change, and not the actual values, which is less than
422: ideal.</p>
423:
1.1011 mike 424: </div><h4 id="the-summary-element"><span class="secno">4.11.2 </span>The <dfn><code>summary</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
1.729 mike 425: <dd>None.</dd>
1.1002 mike 426: <dt>Contexts in which this element can be used:</dt>
1.729 mike 427: <dd>As the first child of a <code><a href="#the-details-element">details</a></code> element.</dd>
428: <dt>Content model:</dt>
1.987 mike 429: <dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
1.729 mike 430: <dt>Content attributes:</dt>
1.987 mike 431: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.729 mike 432: <dt>DOM interface:</dt>
1.987 mike 433: <dd>Uses <code><a href="elements.html#htmlelement">HTMLElement</a></code>.</dd>
434: </dl><p>The <code><a href="#the-summary-element">summary</a></code> element <a href="rendering.html#represents">represents</a> a
1.729 mike 435: summary, caption, or legend for the rest of the contents of the
436: <code><a href="#the-summary-element">summary</a></code> element's parent <code><a href="#the-details-element">details</a></code>
1.1030 mike 437: element<span class="impl">, if any</span>.</p><h4 id="the-command-element"><span class="secno">4.11.3 </span>The <dfn id="the-command"><code>command</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
1.987 mike 438: <dd><a href="content-models.html#metadata-content">Metadata content</a>.</dd>
439: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
440: <dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
1.1002 mike 441: <dt>Contexts in which this element can be used:</dt>
1.987 mike 442: <dd>Where <a href="content-models.html#metadata-content">metadata content</a> is expected.</dd>
443: <dd>Where <a href="content-models.html#phrasing-content">phrasing content</a> is expected.</dd>
1.1 mike 444: <dt>Content model:</dt>
445: <dd>Empty.</dd>
446: <dt>Content attributes:</dt>
1.987 mike 447: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 448: <dd><code title="attr-command-type"><a href="#attr-command-type">type</a></code></dd>
449: <dd><code title="attr-command-label"><a href="#attr-command-label">label</a></code></dd>
450: <dd><code title="attr-command-icon"><a href="#attr-command-icon">icon</a></code></dd>
451: <dd><code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code></dd>
452: <dd><code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code></dd>
453: <dd><code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code></dd>
1.1029 mike 454:
1.1 mike 455: <dd>Also, the <code title="attr-command-title"><a href="#attr-command-title">title</a></code> attribute has special semantics on this element.</dd>
456: <dt>DOM interface:</dt>
457: <dd>
1.987 mike 458: <pre class="idl">interface <dfn id="htmlcommandelement">HTMLCommandElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 459: attribute DOMString <a href="#dom-command-type" title="dom-command-type">type</a>;
460: attribute DOMString <a href="#dom-command-label" title="dom-command-label">label</a>;
461: attribute DOMString <a href="#dom-command-icon" title="dom-command-icon">icon</a>;
462: attribute boolean <a href="#dom-command-disabled" title="dom-command-disabled">disabled</a>;
463: attribute boolean <a href="#dom-command-checked" title="dom-command-checked">checked</a>;
1.1029 mike 464: attribute DOMString <a href="#dom-command-radiogroup" title="dom-command-radiogroup">radiogroup</a>;};</pre>
1.1 mike 465: </dd>
1.1030 mike 466: </dl><p>The <code><a href="#the-command-element">command</a></code> element represents a command that the user
1.1007 mike 467: can invoke.</p><p>A command can be part of a context menu or toolbar, using the
1.1030 mike 468: <code><a href="#the-menu-element">menu</a></code> element, or can be put anywhere else in the page,
1.1029 mike 469: to define a keyboard shortcut.</p><p>The <dfn id="attr-command-type" title="attr-command-type"><code>type</code></dfn>
1.1 mike 470: attribute indicates the kind of command: either a normal command
471: with an associated action, or a state or option that can be toggled,
1.987 mike 472: or a selection of one item from a list of items.</p><p>The attribute is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a> with three
1.289 mike 473: keywords and states. The "<dfn id="attr-command-type-keyword-command" title="attr-command-type-keyword-command"><code>command</code></dfn>"
474: keyword maps to the <a href="#attr-command-type-state-command" title="attr-command-type-state-command">Command</a> state, the
1.520 mike 475: "<dfn id="attr-command-type-keyword-checkbox" title="attr-command-type-keyword-checkbox"><code>checkbox</code></dfn>"
1.289 mike 476: keyword maps to the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state, and
477: the "<dfn id="attr-command-type-keyword-radio" title="attr-command-type-keyword-radio"><code>radio</code></dfn>"
1.1 mike 478: keyword maps to the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state. The
1.117 mike 479: <i>missing value default</i> is the <a href="#attr-command-type-state-command" title="attr-command-type-state-command">Command</a> state.</p><dl><dt>The <dfn id="attr-command-type-state-command" title="attr-command-type-state-command">Command</dfn> state</dt>
1.1 mike 480:
1.987 mike 481: <dd><p>The element <a href="rendering.html#represents">represents</a> a normal command with an associated action.</p></dd>
1.1 mike 482:
483: <dt>The <dfn id="attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</dfn> state</dt>
484:
1.987 mike 485: <dd><p>The element <a href="rendering.html#represents">represents</a> a state or option that can be toggled.</p></dd>
1.1 mike 486:
487: <dt>The <dfn id="attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</dfn> state</dt>
488:
1.987 mike 489: <dd><p>The element <a href="rendering.html#represents">represents</a> a selection of one item from a list of items.</p></dd>
1.1 mike 490:
491: </dl><p>The <dfn id="attr-command-label" title="attr-command-label"><code>label</code></dfn>
1.718 mike 492: attribute gives the name of the command, as shown to the user. The
493: <code title="attr-command-label"><a href="#attr-command-label">label</a></code> attribute must be
494: specified and must have a value that is not the empty string.</p><p>The <dfn id="attr-command-title" title="attr-command-title"><code>title</code></dfn>
1.1 mike 495: attribute gives a hint describing the command, which might be shown
1.117 mike 496: to the user to help him.</p><p>The <dfn id="attr-command-icon" title="attr-command-icon"><code>icon</code></dfn>
1.1 mike 497: attribute gives a picture that represents the command. If the
498: attribute is specified, the attribute's value must contain a
1.987 mike 499: <a href="urls.html#valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by
500: spaces</a>. <span class="impl">To obtain the <a href="urls.html#absolute-url">absolute
1.913 mike 501: URL</a> of the icon when the attribute's value is not the empty
1.987 mike 502: string, the attribute's value must be <a href="urls.html#resolve-a-url" title="resolve a
1.913 mike 503: url">resolved</a> relative to the element. When the attribute is
1.987 mike 504: absent, or its value is the empty string, or <a href="urls.html#resolve-a-url" title="resolve a
1.1029 mike 505: url">resolving</a> its value fails, there is no icon.</span></p><p>The <dfn id="attr-command-disabled" title="attr-command-disabled"><code>disabled</code></dfn> attribute
1.987 mike 506: is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that, if present, indicates that
1.117 mike 507: the command is not available in the current state.</p><p class="note">The distinction between <code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code> and <code title="attr-hidden"><a href="editing.html#the-hidden-attribute">hidden</a></code> is subtle. A command would be
1.1 mike 508: disabled if, in the same context, it could be enabled if only
509: certain aspects of the situation were changed. A command would be
510: marked as hidden if, in that situation, the command will never be
511: enabled. For example, in the context menu for a water faucet, the
512: command "open" might be disabled if the faucet is already open, but
513: the command "eat" would be marked hidden since the faucet could
1.117 mike 514: never be eaten.</p><p>The <dfn id="attr-command-checked" title="attr-command-checked"><code>checked</code></dfn>
1.987 mike 515: attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that, if present,
1.1 mike 516: indicates that the command is selected. The attribute must be
517: omitted unless the <code title="attr-command-type"><a href="#attr-command-type">type</a></code>
518: attribute is in either the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state or
519: the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a>
1.117 mike 520: state.</p><p>The <dfn id="attr-command-radiogroup" title="attr-command-radiogroup"><code>radiogroup</code></dfn>
1.1 mike 521: attribute gives the name of the group of commands that will be
522: toggled when the command itself is toggled, for commands whose <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute has the value "<code title="">radio</code>". The scope of the name is the child list of
1.1029 mike 523: the parent element. The attribute must be omitted unless the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state.</p><div class="impl">
1.1 mike 524:
1.999 mike 525: <p>The <dfn id="dom-command-type" title="dom-command-type"><code>type</code></dfn> IDL
526: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
527: same name, <a href="common-dom-interfaces.html#limited-to-only-known-values">limited to only known values</a>.</p>
528:
1.1029 mike 529: <p>The <dfn id="dom-command-label" title="dom-command-label"><code>label</code></dfn>, <dfn id="dom-command-icon" title="dom-command-icon"><code>icon</code></dfn>, <dfn id="dom-command-disabled" title="dom-command-disabled"><code>disabled</code></dfn>, <dfn id="dom-command-checked" title="dom-command-checked"><code>checked</code></dfn>, and <dfn id="dom-command-radiogroup" title="dom-command-radiogroup"><code>radiogroup</code></dfn> IDL attributes must <a href="common-dom-interfaces.html#reflect">reflect</a> the respective content
1.1 mike 530: attributes of the same name.</p>
531:
1.987 mike 532: <p>The element's <a href="content-models.html#activation-behavior">activation behavior</a> depends on the
1.1 mike 533: value of the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute
534: of the element, as follows:</p>
535:
536: <dl class="switch"><dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
537: in the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state</dt>
538:
539: <dd><p>If the element has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, the UA must
540: remove that attribute. Otherwise, the UA must add a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, with the
541: literal value <code title="">checked</code>. The UA must then
1.788 mike 542: <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at the
1.1 mike 543: element.</p></dd>
544:
545:
546: <dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
547: in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state</dt>
548:
549: <dd><p>If the element has a parent, then the UA must walk the list
550: of child nodes of that parent element, and for each node that is a
1.1030 mike 551: <code><a href="#the-command-element">command</a></code> element, if that element has a <code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code> attribute whose
1.1 mike 552: value exactly matches the current element's (treating missing <code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code> attributes as if
553: they were the empty string), and has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, must remove
554: that attribute.</p>
555:
556: <p>Then, the element's <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute attribute
557: must be set to the literal value <code title="">checked</code> and
1.788 mike 558: the user agent must <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code>
1.1 mike 559: event</a> at the element.</p></dd>
560:
561:
562: <dt>Otherwise</dt>
563:
1.987 mike 564: <dd><p>The element has no <a href="content-models.html#activation-behavior">activation behavior</a>.</p></dd>
1.1 mike 565:
1.875 mike 566: </dl><p class="note">Firing a synthetic <code title="event-click"><a href="infrastructure.html#event-click">click</a></code> event at the element does not cause
1.1 mike 567: any of the actions described above to happen.</p>
568:
1.1029 mike 569:
1.1030 mike 570: </div><p class="note"><code><a href="#the-command-element">command</a></code> elements are not rendered
571: unless they <a href="#the-menu-element" title="menu">form part of a menu</a>.</p><div class="example">
1.520 mike 572:
573: <p>Here is an example of a toolbar with three buttons that let the
574: user toggle between left, center, and right alignment. One could
575: imagine such a toolbar as part of a text editor. The toolbar also
576: has a separator followed by another button labeled "Publish",
577: though that button is disabled.</p>
578:
579: <pre><menu type="toolbar">
580: <command type="radio" radiogroup="alignment" checked="checked"
581: label="Left" icon="icons/alL.png" onclick="setAlign('left')">
582: <command type="radio" radiogroup="alignment"
583: label="Center" icon="icons/alC.png" onclick="setAlign('center')">
584: <command type="radio" radiogroup="alignment"
585: label="Right" icon="icons/alR.png" onclick="setAlign('right')">
586: <hr>
587: <command type="command" disabled
588: label="Publish" icon="icons/pub.png" onclick="publish()">
589: </menu></pre>
590:
1.1030 mike 591: </div><h4 id="the-menu-element"><span class="secno">4.11.4 </span>The <dfn id="menus"><code>menu</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
1.987 mike 592: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
593: <dd>If the element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#toolbar-state" title="toolbar state">toolbar</a> state: <a href="content-models.html#interactive-content">Interactive content</a>.</dd>
1.1002 mike 594: <dt>Contexts in which this element can be used:</dt>
1.987 mike 595: <dd>Where <a href="content-models.html#flow-content">flow content</a> is expected.</dd>
1.1 mike 596: <dt>Content model:</dt>
1.987 mike 597: <dd>Either: Zero or more <code><a href="grouping-content.html#the-li-element">li</a></code> elements.</dd>
598: <dd>Or: <a href="content-models.html#flow-content">Flow content</a>.</dd>
1.1 mike 599: <dt>Content attributes:</dt>
1.987 mike 600: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 601: <dd><code title="attr-menu-type"><a href="#attr-menu-type">type</a></code></dd>
602: <dd><code title="attr-menu-label"><a href="#attr-menu-label">label</a></code></dd>
603: <dt>DOM interface:</dt>
604: <dd>
1.987 mike 605: <pre class="idl">interface <dfn id="htmlmenuelement">HTMLMenuElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 606: attribute DOMString <a href="#dom-menu-type" title="dom-menu-type">type</a>;
607: attribute DOMString <a href="#dom-menu-label" title="dom-menu-label">label</a>;
608: };</pre>
1.1030 mike 609: </dd></dl><p>The <code><a href="#the-menu-element">menu</a></code> element represents a list of commands.</p><p>The <dfn id="attr-menu-type" title="attr-menu-type"><code>type</code></dfn> attribute
1.987 mike 610: is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a> indicating the kind of menu
1.1 mike 611: being declared. The attribute has three states. The <code title="attr-menu-type-context">context</code> keyword maps to the
612: <dfn id="context-menu-state" title="context menu state">context menu</dfn> state, in which
613: the element is declaring a context menu. The <code title="attr-menu-type-toolbar">toolbar</code> keyword maps to the
1.385 mike 614: <dfn id="toolbar-state" title="toolbar state">toolbar</dfn> state, in which the
615: element is declaring a toolbar. The attribute may also be
1.1 mike 616: omitted. The <i>missing value default</i> is the <dfn id="list-state" title="list
617: state">list</dfn> state, which indicates that the element is merely
618: a list of commands that is neither declaring a context menu nor
1.1030 mike 619: defining a toolbar.</p><p>If a <code><a href="#the-menu-element">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#context-menu-state" title="context menu state">context menu</a> state, then the
1.987 mike 620: element <a href="rendering.html#represents">represents</a> the commands of a context menu, and
1.1 mike 621: the user can only interact with the commands if that context menu is
1.1030 mike 622: activated.</p><p>If a <code><a href="#the-menu-element">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#toolbar-state" title="toolbar state">toolbar</a> state, then the element
1.987 mike 623: <a href="rendering.html#represents">represents</a> a list of active commands that the user can
1.1030 mike 624: immediately interact with.</p><p>If a <code><a href="#the-menu-element">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#list-state" title="list state">list</a> state, then the element either
1.987 mike 625: <a href="rendering.html#represents">represents</a> an unordered list of items (each represented
626: by an <code><a href="grouping-content.html#the-li-element">li</a></code> element), each of which represents a command
1.1 mike 627: that the user can perform or activate, or, if the element has no
1.987 mike 628: <code><a href="grouping-content.html#the-li-element">li</a></code> element children, <a href="content-models.html#flow-content">flow content</a>
1.117 mike 629: describing available commands.</p><p>The <dfn id="attr-menu-label" title="attr-menu-label"><code>label</code></dfn>
1.1 mike 630: attribute gives the label of the menu. It is used by user agents to
631: display nested menus in the UI. For example, a context menu
632: containing another menu would use the nested menu's <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute for the submenu's
1.117 mike 633: menu label.</p><div class="impl">
1.1 mike 634:
1.186 mike 635: <p>The <dfn id="dom-menu-type" title="dom-menu-type"><code>type</code></dfn> and <dfn id="dom-menu-label" title="dom-menu-label"><code>label</code></dfn> IDL attributes must
1.987 mike 636: <a href="common-dom-interfaces.html#reflect">reflect</a> the respective content attributes of the same
1.1 mike 637: name.</p>
638:
1.1030 mike 639: </div><h5 id="menus-intro"><span class="secno">4.11.4.1 </span>Introduction</h5><p><i>This section is non-normative.</i></p><p>The <code><a href="#the-menu-element">menu</a></code> element is used to define context menus and
1.385 mike 640: toolbars.</p><p>For example, the following represents a toolbar with three menu
1.148 mike 641: buttons on it, each of which has a dropdown menu with a series of
642: options:</p><pre><menu type="toolbar">
1.1 mike 643: <li>
644: <menu label="File">
645: <button type="button" onclick="fnew()">New...</button>
646: <button type="button" onclick="fopen()">Open...</button>
1.290 mike 647: <button type="button" onclick="fsave()">Save</button>
1.1 mike 648: <button type="button" onclick="fsaveas()">Save as...</button>
649: </menu>
650: </li>
651: <li>
652: <menu label="Edit">
653: <button type="button" onclick="ecopy()">Copy</button>
654: <button type="button" onclick="ecut()">Cut</button>
655: <button type="button" onclick="epaste()">Paste</button>
656: </menu>
657: </li>
658: <li>
659: <menu label="Help">
660: <li><a href="help.html">Help</a></li>
661: <li><a href="about.html">About</a></li>
662: </menu>
663: </li>
1.1037 mike 664: </menu></pre><p>In a supporting user agent, this might look like this:</p><p><img alt="A toolbar with three buttons, labeled 'File', 'Edit', and 'Help'; where if you select the 'Edit' button you get a drop-down menu with three more options, 'Copy', 'Cut', and 'Paste'." height="101" src="http://dev.w3.org/html5/spec/images/sample-toolbar-1.png" width="303"></p><p>In a legacy user agent, the above would look like a bulleted list
1.148 mike 665: with three items, the first of which has four buttons, the second of
666: which has three, and the third of which has two nested bullet points
667: with two items consisting of links.</p><hr><p>The following implements a similar toolbar, with a single button
668: whose values, when selected, redirect the user to Web sites.</p><pre><form action="redirect.cgi">
669: <menu type="toolbar">
1.1 mike 670: <label for="goto">Go to...</label>
671: <menu label="Go">
1.1029 mike 672: <select id="goto">
1.1 mike 673: <option value="" selected="selected"> Select site: </option>
674: <option value="http://www.apple.com/"> Apple </option>
675: <option value="http://www.mozilla.org/"> Mozilla </option>
676: <option value="http://www.opera.com/"> Opera </option>
677: </select>
678: <span><input type="submit" value="Go"></span>
679: </menu>
680: </menu>
1.148 mike 681: </form></pre><p>The behavior in supporting user agents is similar to the example
1.875 mike 682: above, but here the legacy behavior consists of a single
1.987 mike 683: <code><a href="the-button-element.html#the-select-element">select</a></code> element with a submit button. The submit button
1.148 mike 684: doesn't appear in the toolbar, because it is not a direct child of
1.1030 mike 685: the <code><a href="#the-menu-element">menu</a></code> element or of its <code><a href="grouping-content.html#the-li-element">li</a></code>
1.148 mike 686: children.</p><div class="impl">
1.1 mike 687:
1.1011 mike 688: <h5 id="building-menus-and-toolbars"><span class="secno">4.11.4.2 </span><dfn>Building menus and toolbars</dfn></h5>
1.1 mike 689:
1.385 mike 690: <p>A menu (or toolbar) consists of a list of zero or more of the
1.1 mike 691: following components:</p>
692:
1.987 mike 693: <ul class="brief"><li><a href="commands.html#concept-command" title="concept-command">Commands</a>, which can be marked as default commands</li>
1.1 mike 694: <li>Separators</li>
695: <li>Other menus (which allows the list to be nested)</li>
1.1030 mike 696: </ul><p>The list corresponding to a particular <code><a href="#the-menu-element">menu</a></code> element
1.1 mike 697: is built by iterating over its child nodes. For each child node in
698: <a href="infrastructure.html#tree-order">tree order</a>, the required behavior depends on what the
699: node is, as follows:</p>
700:
1.987 mike 701: <dl class="switch"><dt>An element that <a href="commands.html#concept-command" title="concept-command">defines a command</a></dt>
1.1 mike 702:
1.1029 mike 703: <dd>Append the command to the menu, respecting its <a href="commands.html#concept-facet" title="concept-facet">facets</a>. </dd>
1.1 mike 704:
705:
1.987 mike 706: <dt>An <code><a href="grouping-content.html#the-hr-element">hr</a></code> element</dt>
707: <dt>An <code><a href="the-button-element.html#the-option-element">option</a></code> element that has a <code title="attr-option-value"><a href="the-button-element.html#attr-option-value">value</a></code> attribute set to the empty
708: string, and has a <code title="attr-option-disabled"><a href="the-button-element.html#attr-option-disabled">disabled</a></code> attribute, and whose
1.804 mike 709: <code><a href="infrastructure.html#textcontent">textContent</a></code> consists of a string of one or more
1.1 mike 710: hyphens (U+002D HYPHEN-MINUS)</dt>
711:
712: <dd>Append a separator to the menu.</dd>
713:
714:
1.987 mike 715: <dt>An <code><a href="grouping-content.html#the-li-element">li</a></code> element</dt>
1.1 mike 716: <dt>A <code><a href="forms.html#the-label-element">label</a></code> element</dt>
717:
718: <dd>Iterate over the children of the element.</dd>
719:
720:
1.1030 mike 721: <dt>A <code><a href="#the-menu-element">menu</a></code> element with no <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute</dt>
1.987 mike 722: <dt>A <code><a href="the-button-element.html#the-select-element">select</a></code> element</dt>
1.1 mike 723:
724: <dd>Append a separator to the menu, then iterate over the children
1.1030 mike 725: of the <code><a href="#the-menu-element">menu</a></code> or <code><a href="the-button-element.html#the-select-element">select</a></code> element, then
1.1 mike 726: append another separator.</dd>
727:
1.1029 mike 728:
1.1 mike 729:
730:
1.1030 mike 731: <dt>A <code><a href="#the-menu-element">menu</a></code> element with a <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute</dt>
1.987 mike 732: <dt>An <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> element with a <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute</dt>
1.1 mike 733:
734: <dd>Append a submenu to the menu, using the value of the element's
735: <code title="">label</code> attribute as the label of the menu. The
736: submenu must be constructed by taking the element and creating a
737: new menu for it using the complete process described in this
738: section.</dd>
739:
740:
741: <dt>Any other node</dt>
742:
743: <dd><a href="infrastructure.html#ignore">Ignore</a> the node.</dd>
744:
745: </dl><p>Once all the nodes have been processed as described above, the
746: user agent must the post-process the menu as follows:</p>
747:
1.521 mike 748: <ol><li>Except for separators, any menu item with no label, or whose
749: label is the empty string, must be removed.</li>
1.1 mike 750:
1.521 mike 751: <li>Any sequence of two or more separators in a row must be
752: collapsed to a single separator.</li>
1.1 mike 753:
1.521 mike 754: <li>Any separator at the start or end of the menu must be
755: removed.</li>
1.1 mike 756:
1.1011 mike 757: </ol></div><h5 id="context-menus"><span class="secno">4.11.4.3 </span><dfn>Context menus</dfn></h5><p>The <dfn id="attr-contextmenu" title="attr-contextmenu"><code>contextmenu</code></dfn>
1.1 mike 758: attribute gives the element's <a href="#context-menus" title="context menus">context
1.1030 mike 759: menu</a>. The value must be the <a href="elements.html#concept-id" title="concept-id">ID</a> of a <code><a href="#the-menu-element">menu</a></code> element
1.1 mike 760: in the DOM. <span class="impl">If the node that would be obtained by
1.875 mike 761: the invoking the <code title="dom-Document-getElementById"><a href="infrastructure.html#dom-document-getelementbyid">getElementById()</a></code> method
762: using the attribute's value as the only argument is null or not a
1.1030 mike 763: <code><a href="#the-menu-element">menu</a></code> element, then the element has no assigned context
1.1 mike 764: menu. Otherwise, the element's assigned context menu is the element
1.117 mike 765: so identified.</span></p><div class="impl">
1.1 mike 766:
767: <p>When an element's context menu is requested (e.g. by the user
1.1005 mike 768: right-clicking the element, or pressing a context menu key), the
769: user agent must apply the appropriate rules from the following
770: list:</p>
771:
772: <dl class="switch"><dt>If the user requested a context menu using a pointing device</dt>
773:
1.1039 ! mike 774: <dd><p>The user agent must fire an event with the name <code title="event-contextmenu">contextmenu</code>, that bubbles and is
1.1032 mike 775: cancelable, and that uses the <code><a href="infrastructure.html#mouseevent">MouseEvent</a></code> interface, at
1.1005 mike 776: the element for which the menu was requested. The context
777: information of the event must be set to the same values as the last
1.1039 ! mike 778: <code><a href="infrastructure.html#mouseevent">MouseEvent</a></code> user interaction event that was fired as
! 779: part of the gesture that that was interpreted as a request for the
! 780: context menu.</p></dd>
1.1005 mike 781:
782: <dt>Otherwise</dt>
783:
784: <dd><p>The user agent must <a href="webappapis.html#fire-a-synthetic-mouse-event" title="fire a synthetic mouse
785: event">fire a synthetic mouse event named <code title="event-contextmenu">contextmenu</code></a> that bubbles
786: and is cancelable at the element for which the menu was
787: requested.</p></dd>
1.1 mike 788:
1.1005 mike 789: </dl><p class="note">Typically, therefore, the firing of the <code title="event-contextmenu">contextmenu</code> event will be the
1.1 mike 790: default action of a <code title="mouseup">mouseup</code> or <code title="event-keyup">keyup</code> event. The exact sequence of events
791: is UA-dependent, as it will vary based on platform conventions.</p>
792:
793: <p>The default action of the <code title="event-contextmenu">contextmenu</code> event depends on
794: whether the element or one of its ancestors has a context menu
795: assigned (using the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> attribute) or not. If
796: there is no context menu assigned, the default action must be for
797: the user agent to show its default context menu, if it has one.</p>
798:
799: <p>If the element or one of its ancestors <em>does</em> have a
1.788 mike 800: context menu assigned, then the user agent must <a href="webappapis.html#fire-a-simple-event">fire a simple
1.454 mike 801: event</a> named <code title="event-show">show</code> at the
1.1030 mike 802: <code><a href="#the-menu-element">menu</a></code> element of the context menu of the nearest
1.1 mike 803: ancestor (including the element itself) with one assigned.</p>
1.1029 mike 804:
1.1 mike 805:
806: <p>The default action of <em>this</em> event is that the user agent
1.385 mike 807: must show a context menu <a href="#building-menus-and-toolbars" title="building menus and
1.1030 mike 808: toolbars">built</a> from the <code><a href="#the-menu-element">menu</a></code> element.</p>
1.1 mike 809:
810: <p>The user agent may also provide access to its default context
811: menu, if any, with the context menu shown. For example, it could
812: merge the menu items from the two menus together, or provide the
813: page's context menu as a submenu of the default menu.</p>
814:
815: <p>If the user dismisses the menu without making a selection,
816: nothing in particular happens.</p>
817:
1.987 mike 818: <p>If the user selects a menu item that represents a <a href="commands.html#concept-command" title="concept-command">command</a>, then the UA must invoke
819: that command's <a href="commands.html#command-facet-action" title="command-facet-Action">Action</a>.</p>
1.1 mike 820:
821: <p>Context menus must not, while being shown, reflect changes in the
1.521 mike 822: DOM; they are constructed as the default action of the <code title="event-show">show</code> event and must remain as constructed
823: until dismissed.</p>
1.1 mike 824:
825: <p>User agents may provide means for bypassing the context menu
826: processing model, ensuring that the user can always access the UA's
827: default context menus. For example, the user agent could handle
828: right-clicks that have the Shift key depressed in such a way that it
829: does not fire the <code title="event-contextmenu">contextmenu</code>
830: event and instead always shows the default context menu.</p>
831:
832: <p>The <dfn id="dom-contextmenu" title="dom-contextMenu"><code>contextMenu</code></dfn>
1.1024 mike 833: IDL attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> content attribute.</p>
1.1 mike 834:
1.520 mike 835: </div><div class="example">
836:
837: <p>Here is an example of a context menu for an input control:</p>
838:
839: <pre><form name="npc">
840: <label>Character name: <input name=char type=text contextmenu=namemenu required></label>
841: <menu type=context id=namemenu>
842: <command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()">
843: <command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)">
844: </menu>
845: </form></pre>
846:
1.994 mike 847: <p>This adds two items to the control's context menu, one called
1.520 mike 848: "Pick random name", and one called "Prefill other fields based on
849: name". They invoke scripts that are not shown in the example
850: above.</p>
851:
1.117 mike 852: </div><div class="impl">
1.1 mike 853:
1.1011 mike 854: <h5 id="toolbars"><span class="secno">4.11.4.4 </span><dfn>Toolbars</dfn></h5>
1.1 mike 855:
1.1030 mike 856: <p>When a <code><a href="#the-menu-element">menu</a></code> element has a <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute in the <a href="#toolbar-state" title="toolbar state">toolbar</a> state, then the user agent
1.385 mike 857: must <a href="#building-menus-and-toolbars" title="building menus and toolbars">build</a> the
1.1030 mike 858: menu for that <code><a href="#the-menu-element">menu</a></code> element, and use the result in the
1.1 mike 859: rendering.</p>
860:
861: <p>The user agent must reflect changes made to the
1.1030 mike 862: <code><a href="#the-menu-element">menu</a></code>'s DOM, by immediately <a href="#building-menus-and-toolbars" title="building menus
1.385 mike 863: and toolbars">rebuilding</a> the menu.</p>
1.1 mike 864:
1.117 mike 865: </div></body></html>
Webmaster