Annotation of html5/spec/interactive-elements.html, revision 1.1034
1.866 mike 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.885 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.1028 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.1028 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">
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
360: legend (e.g. "Details").</span></p><p>The <dfn id="attr-details-open" title="attr-details-open"><code>open</code></dfn>
1.987 mike 361: content attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a>. If present,
1.1 mike 362: it indicates that the details are to be shown to the user. If the
1.117 mike 363: attribute is absent, the details are not to be shown.</p><div class="impl">
1.1 mike 364:
1.1033 mike 365: <p>When the element is created, if the attribute is absent, the
366: details should be hidden; if the attribute is absent, the details
367: should be shown. Subsequently, if the attribute is removed, then the
368: details should be hidden; if the attribute is added, the details
369: should be shown.</p>
1.1 mike 370:
371: <p>The user agent should allow the user to request that the details
372: be shown or hidden. To honor a request for the details to be shown,
373: the user agent must set the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> attribute on the element to
374: the value <code title="">open</code>. To honor a request for the
375: details 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
376: element.</p>
377:
1.1024 mike 378: <p>The <dfn id="dom-details-open" title="dom-details-open"><code>open</code></dfn> IDL
1.987 mike 379: 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 380:
1.271 mike 381: </div><div class="example">
382:
383: <p>The following example shows the <code><a href="#the-details-element">details</a></code> element
384: being used to hide technical details in a progress report.</p>
385:
386: <pre><section class="progress window">
387: <h1>Copying "Really Achieving Your Childhood Dreams"</h1>
388: <details>
1.876 mike 389: <summary>Copying... <progress max="375505392" value="97543282"></progress> 25%</summary>
1.729 mike 390: <dl>
391: <dt>Transfer rate:</dt> <dd>452KB/s</dd>
392: <dt>Local filename:</dt> <dd>/home/rpausch/raycd.m4v</dd>
393: <dt>Remote filename:</dt> <dd>/var/www/lectures/raycd.m4v</dd>
394: <dt>Duration:</dt> <dd>01:16:27</dd>
395: <dt>Color profile:</dt> <dd>SD (6-1-6)</dd>
396: <dt>Dimensions:</dt> <dd>320×240</dd>
397: </dl>
1.271 mike 398: </details>
399: </section></pre>
400:
1.718 mike 401: </div><div class="example">
402:
403: <p>The following shows how a <code><a href="#the-details-element">details</a></code> element can be
404: used to hide some controls by default:</p>
405:
406: <pre><details>
1.1004 mike 407: <summary><label for=fn>Name & Extension:</label></summary>
408: <p><input type=text id=fn name=fn value="Pillar Magazine.pdf">
1.729 mike 409: <p><label><input type=checkbox name=ext checked> Hide extension</label>
1.718 mike 410: </details></pre>
411:
1.1031 mike 412: <p>One could use this in conjunction with other <code><a href="#the-details-element">details</a></code>
1.718 mike 413: in a list to allow the user to collapse a set of fields down to a
414: small set of headings, with the ability to open each one.</p>
415:
1.1002 mike 416: <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 417:
1.729 mike 418: <p>In these examples, the summary really just summarises what the
419: controls can change, and not the actual values, which is less than
420: ideal.</p>
421:
1.1011 mike 422: </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 423: <dd>None.</dd>
1.1002 mike 424: <dt>Contexts in which this element can be used:</dt>
1.729 mike 425: <dd>As the first child of a <code><a href="#the-details-element">details</a></code> element.</dd>
426: <dt>Content model:</dt>
1.987 mike 427: <dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
1.729 mike 428: <dt>Content attributes:</dt>
1.987 mike 429: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.729 mike 430: <dt>DOM interface:</dt>
1.987 mike 431: <dd>Uses <code><a href="elements.html#htmlelement">HTMLElement</a></code>.</dd>
432: </dl><p>The <code><a href="#the-summary-element">summary</a></code> element <a href="rendering.html#represents">represents</a> a
1.729 mike 433: summary, caption, or legend for the rest of the contents of the
434: <code><a href="#the-summary-element">summary</a></code> element's parent <code><a href="#the-details-element">details</a></code>
1.1030 mike 435: 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 436: <dd><a href="content-models.html#metadata-content">Metadata content</a>.</dd>
437: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
438: <dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
1.1002 mike 439: <dt>Contexts in which this element can be used:</dt>
1.987 mike 440: <dd>Where <a href="content-models.html#metadata-content">metadata content</a> is expected.</dd>
441: <dd>Where <a href="content-models.html#phrasing-content">phrasing content</a> is expected.</dd>
1.1 mike 442: <dt>Content model:</dt>
443: <dd>Empty.</dd>
444: <dt>Content attributes:</dt>
1.987 mike 445: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 446: <dd><code title="attr-command-type"><a href="#attr-command-type">type</a></code></dd>
447: <dd><code title="attr-command-label"><a href="#attr-command-label">label</a></code></dd>
448: <dd><code title="attr-command-icon"><a href="#attr-command-icon">icon</a></code></dd>
449: <dd><code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code></dd>
450: <dd><code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code></dd>
451: <dd><code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code></dd>
1.1029 mike 452:
1.1 mike 453: <dd>Also, the <code title="attr-command-title"><a href="#attr-command-title">title</a></code> attribute has special semantics on this element.</dd>
454: <dt>DOM interface:</dt>
455: <dd>
1.987 mike 456: <pre class="idl">interface <dfn id="htmlcommandelement">HTMLCommandElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 457: attribute DOMString <a href="#dom-command-type" title="dom-command-type">type</a>;
458: attribute DOMString <a href="#dom-command-label" title="dom-command-label">label</a>;
459: attribute DOMString <a href="#dom-command-icon" title="dom-command-icon">icon</a>;
460: attribute boolean <a href="#dom-command-disabled" title="dom-command-disabled">disabled</a>;
461: attribute boolean <a href="#dom-command-checked" title="dom-command-checked">checked</a>;
1.1029 mike 462: attribute DOMString <a href="#dom-command-radiogroup" title="dom-command-radiogroup">radiogroup</a>;};</pre>
1.1 mike 463: </dd>
1.1030 mike 464: </dl><p>The <code><a href="#the-command-element">command</a></code> element represents a command that the user
1.1007 mike 465: can invoke.</p><p>A command can be part of a context menu or toolbar, using the
1.1030 mike 466: <code><a href="#the-menu-element">menu</a></code> element, or can be put anywhere else in the page,
1.1029 mike 467: to define a keyboard shortcut.</p><p>The <dfn id="attr-command-type" title="attr-command-type"><code>type</code></dfn>
1.1 mike 468: attribute indicates the kind of command: either a normal command
469: with an associated action, or a state or option that can be toggled,
1.987 mike 470: 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 471: keywords and states. The "<dfn id="attr-command-type-keyword-command" title="attr-command-type-keyword-command"><code>command</code></dfn>"
472: keyword maps to the <a href="#attr-command-type-state-command" title="attr-command-type-state-command">Command</a> state, the
1.520 mike 473: "<dfn id="attr-command-type-keyword-checkbox" title="attr-command-type-keyword-checkbox"><code>checkbox</code></dfn>"
1.289 mike 474: keyword maps to the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state, and
475: the "<dfn id="attr-command-type-keyword-radio" title="attr-command-type-keyword-radio"><code>radio</code></dfn>"
1.1 mike 476: keyword maps to the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state. The
1.117 mike 477: <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 478:
1.987 mike 479: <dd><p>The element <a href="rendering.html#represents">represents</a> a normal command with an associated action.</p></dd>
1.1 mike 480:
481: <dt>The <dfn id="attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</dfn> state</dt>
482:
1.987 mike 483: <dd><p>The element <a href="rendering.html#represents">represents</a> a state or option that can be toggled.</p></dd>
1.1 mike 484:
485: <dt>The <dfn id="attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</dfn> state</dt>
486:
1.987 mike 487: <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 488:
489: </dl><p>The <dfn id="attr-command-label" title="attr-command-label"><code>label</code></dfn>
1.718 mike 490: attribute gives the name of the command, as shown to the user. The
491: <code title="attr-command-label"><a href="#attr-command-label">label</a></code> attribute must be
492: 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 493: attribute gives a hint describing the command, which might be shown
1.117 mike 494: 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 495: attribute gives a picture that represents the command. If the
496: attribute is specified, the attribute's value must contain a
1.987 mike 497: <a href="urls.html#valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by
498: spaces</a>. <span class="impl">To obtain the <a href="urls.html#absolute-url">absolute
1.913 mike 499: URL</a> of the icon when the attribute's value is not the empty
1.987 mike 500: string, the attribute's value must be <a href="urls.html#resolve-a-url" title="resolve a
1.913 mike 501: url">resolved</a> relative to the element. When the attribute is
1.987 mike 502: absent, or its value is the empty string, or <a href="urls.html#resolve-a-url" title="resolve a
1.1029 mike 503: 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 504: is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that, if present, indicates that
1.117 mike 505: 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 506: disabled if, in the same context, it could be enabled if only
507: certain aspects of the situation were changed. A command would be
508: marked as hidden if, in that situation, the command will never be
509: enabled. For example, in the context menu for a water faucet, the
510: command "open" might be disabled if the faucet is already open, but
511: the command "eat" would be marked hidden since the faucet could
1.117 mike 512: never be eaten.</p><p>The <dfn id="attr-command-checked" title="attr-command-checked"><code>checked</code></dfn>
1.987 mike 513: attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that, if present,
1.1 mike 514: indicates that the command is selected. The attribute must be
515: omitted unless the <code title="attr-command-type"><a href="#attr-command-type">type</a></code>
516: attribute is in either the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state or
517: the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a>
1.117 mike 518: state.</p><p>The <dfn id="attr-command-radiogroup" title="attr-command-radiogroup"><code>radiogroup</code></dfn>
1.1 mike 519: attribute gives the name of the group of commands that will be
520: 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 521: 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 522:
1.999 mike 523: <p>The <dfn id="dom-command-type" title="dom-command-type"><code>type</code></dfn> IDL
524: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
525: same name, <a href="common-dom-interfaces.html#limited-to-only-known-values">limited to only known values</a>.</p>
526:
1.1029 mike 527: <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 528: attributes of the same name.</p>
529:
1.987 mike 530: <p>The element's <a href="content-models.html#activation-behavior">activation behavior</a> depends on the
1.1 mike 531: value of the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute
532: of the element, as follows:</p>
533:
534: <dl class="switch"><dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
535: in the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state</dt>
536:
537: <dd><p>If the element has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, the UA must
538: 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
539: literal value <code title="">checked</code>. The UA must then
1.788 mike 540: <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at the
1.1 mike 541: element.</p></dd>
542:
543:
544: <dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
545: in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state</dt>
546:
547: <dd><p>If the element has a parent, then the UA must walk the list
548: of child nodes of that parent element, and for each node that is a
1.1030 mike 549: <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 550: 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
551: they were the empty string), and has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, must remove
552: that attribute.</p>
553:
554: <p>Then, the element's <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute attribute
555: must be set to the literal value <code title="">checked</code> and
1.788 mike 556: the user agent must <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code>
1.1 mike 557: event</a> at the element.</p></dd>
558:
559:
560: <dt>Otherwise</dt>
561:
1.987 mike 562: <dd><p>The element has no <a href="content-models.html#activation-behavior">activation behavior</a>.</p></dd>
1.1 mike 563:
1.875 mike 564: </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 565: any of the actions described above to happen.</p>
566:
1.1029 mike 567:
1.1030 mike 568: </div><p class="note"><code><a href="#the-command-element">command</a></code> elements are not rendered
569: unless they <a href="#the-menu-element" title="menu">form part of a menu</a>.</p><div class="example">
1.520 mike 570:
571: <p>Here is an example of a toolbar with three buttons that let the
572: user toggle between left, center, and right alignment. One could
573: imagine such a toolbar as part of a text editor. The toolbar also
574: has a separator followed by another button labeled "Publish",
575: though that button is disabled.</p>
576:
577: <pre><menu type="toolbar">
578: <command type="radio" radiogroup="alignment" checked="checked"
579: label="Left" icon="icons/alL.png" onclick="setAlign('left')">
580: <command type="radio" radiogroup="alignment"
581: label="Center" icon="icons/alC.png" onclick="setAlign('center')">
582: <command type="radio" radiogroup="alignment"
583: label="Right" icon="icons/alR.png" onclick="setAlign('right')">
584: <hr>
585: <command type="command" disabled
586: label="Publish" icon="icons/pub.png" onclick="publish()">
587: </menu></pre>
588:
1.1030 mike 589: </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 590: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
591: <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 592: <dt>Contexts in which this element can be used:</dt>
1.987 mike 593: <dd>Where <a href="content-models.html#flow-content">flow content</a> is expected.</dd>
1.1 mike 594: <dt>Content model:</dt>
1.987 mike 595: <dd>Either: Zero or more <code><a href="grouping-content.html#the-li-element">li</a></code> elements.</dd>
596: <dd>Or: <a href="content-models.html#flow-content">Flow content</a>.</dd>
1.1 mike 597: <dt>Content attributes:</dt>
1.987 mike 598: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 599: <dd><code title="attr-menu-type"><a href="#attr-menu-type">type</a></code></dd>
600: <dd><code title="attr-menu-label"><a href="#attr-menu-label">label</a></code></dd>
601: <dt>DOM interface:</dt>
602: <dd>
1.987 mike 603: <pre class="idl">interface <dfn id="htmlmenuelement">HTMLMenuElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 604: attribute DOMString <a href="#dom-menu-type" title="dom-menu-type">type</a>;
605: attribute DOMString <a href="#dom-menu-label" title="dom-menu-label">label</a>;
606: };</pre>
1.1030 mike 607: </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 608: is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a> indicating the kind of menu
1.1 mike 609: being declared. The attribute has three states. The <code title="attr-menu-type-context">context</code> keyword maps to the
610: <dfn id="context-menu-state" title="context menu state">context menu</dfn> state, in which
611: the element is declaring a context menu. The <code title="attr-menu-type-toolbar">toolbar</code> keyword maps to the
1.385 mike 612: <dfn id="toolbar-state" title="toolbar state">toolbar</dfn> state, in which the
613: element is declaring a toolbar. The attribute may also be
1.1 mike 614: omitted. The <i>missing value default</i> is the <dfn id="list-state" title="list
615: state">list</dfn> state, which indicates that the element is merely
616: a list of commands that is neither declaring a context menu nor
1.1030 mike 617: 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 618: element <a href="rendering.html#represents">represents</a> the commands of a context menu, and
1.1 mike 619: the user can only interact with the commands if that context menu is
1.1030 mike 620: 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 621: <a href="rendering.html#represents">represents</a> a list of active commands that the user can
1.1030 mike 622: 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 623: <a href="rendering.html#represents">represents</a> an unordered list of items (each represented
624: by an <code><a href="grouping-content.html#the-li-element">li</a></code> element), each of which represents a command
1.1 mike 625: that the user can perform or activate, or, if the element has no
1.987 mike 626: <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 627: describing available commands.</p><p>The <dfn id="attr-menu-label" title="attr-menu-label"><code>label</code></dfn>
1.1 mike 628: attribute gives the label of the menu. It is used by user agents to
629: display nested menus in the UI. For example, a context menu
630: 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 631: menu label.</p><div class="impl">
1.1 mike 632:
1.186 mike 633: <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 634: <a href="common-dom-interfaces.html#reflect">reflect</a> the respective content attributes of the same
1.1 mike 635: name.</p>
636:
1.1030 mike 637: </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 638: toolbars.</p><p>For example, the following represents a toolbar with three menu
1.148 mike 639: buttons on it, each of which has a dropdown menu with a series of
640: options:</p><pre><menu type="toolbar">
1.1 mike 641: <li>
642: <menu label="File">
643: <button type="button" onclick="fnew()">New...</button>
644: <button type="button" onclick="fopen()">Open...</button>
1.290 mike 645: <button type="button" onclick="fsave()">Save</button>
1.1 mike 646: <button type="button" onclick="fsaveas()">Save as...</button>
647: </menu>
648: </li>
649: <li>
650: <menu label="Edit">
651: <button type="button" onclick="ecopy()">Copy</button>
652: <button type="button" onclick="ecut()">Cut</button>
653: <button type="button" onclick="epaste()">Paste</button>
654: </menu>
655: </li>
656: <li>
657: <menu label="Help">
658: <li><a href="help.html">Help</a></li>
659: <li><a href="about.html">About</a></li>
660: </menu>
661: </li>
1.1002 mike 662: </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 663: with three items, the first of which has four buttons, the second of
664: which has three, and the third of which has two nested bullet points
665: with two items consisting of links.</p><hr><p>The following implements a similar toolbar, with a single button
666: whose values, when selected, redirect the user to Web sites.</p><pre><form action="redirect.cgi">
667: <menu type="toolbar">
1.1 mike 668: <label for="goto">Go to...</label>
669: <menu label="Go">
1.1029 mike 670: <select id="goto">
1.1 mike 671: <option value="" selected="selected"> Select site: </option>
672: <option value="http://www.apple.com/"> Apple </option>
673: <option value="http://www.mozilla.org/"> Mozilla </option>
674: <option value="http://www.opera.com/"> Opera </option>
675: </select>
676: <span><input type="submit" value="Go"></span>
677: </menu>
678: </menu>
1.148 mike 679: </form></pre><p>The behavior in supporting user agents is similar to the example
1.875 mike 680: above, but here the legacy behavior consists of a single
1.987 mike 681: <code><a href="the-button-element.html#the-select-element">select</a></code> element with a submit button. The submit button
1.148 mike 682: doesn't appear in the toolbar, because it is not a direct child of
1.1030 mike 683: 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 684: children.</p><div class="impl">
1.1 mike 685:
1.1011 mike 686: <h5 id="building-menus-and-toolbars"><span class="secno">4.11.4.2 </span><dfn>Building menus and toolbars</dfn></h5>
1.1 mike 687:
1.385 mike 688: <p>A menu (or toolbar) consists of a list of zero or more of the
1.1 mike 689: following components:</p>
690:
1.987 mike 691: <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 692: <li>Separators</li>
693: <li>Other menus (which allows the list to be nested)</li>
1.1030 mike 694: </ul><p>The list corresponding to a particular <code><a href="#the-menu-element">menu</a></code> element
1.1 mike 695: is built by iterating over its child nodes. For each child node in
696: <a href="infrastructure.html#tree-order">tree order</a>, the required behavior depends on what the
697: node is, as follows:</p>
698:
1.987 mike 699: <dl class="switch"><dt>An element that <a href="commands.html#concept-command" title="concept-command">defines a command</a></dt>
1.1 mike 700:
1.1029 mike 701: <dd>Append the command to the menu, respecting its <a href="commands.html#concept-facet" title="concept-facet">facets</a>. </dd>
1.1 mike 702:
703:
1.987 mike 704: <dt>An <code><a href="grouping-content.html#the-hr-element">hr</a></code> element</dt>
705: <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
706: 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 707: <code><a href="infrastructure.html#textcontent">textContent</a></code> consists of a string of one or more
1.1 mike 708: hyphens (U+002D HYPHEN-MINUS)</dt>
709:
710: <dd>Append a separator to the menu.</dd>
711:
712:
1.987 mike 713: <dt>An <code><a href="grouping-content.html#the-li-element">li</a></code> element</dt>
1.1 mike 714: <dt>A <code><a href="forms.html#the-label-element">label</a></code> element</dt>
715:
716: <dd>Iterate over the children of the element.</dd>
717:
718:
1.1030 mike 719: <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 720: <dt>A <code><a href="the-button-element.html#the-select-element">select</a></code> element</dt>
1.1 mike 721:
722: <dd>Append a separator to the menu, then iterate over the children
1.1030 mike 723: 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 724: append another separator.</dd>
725:
1.1029 mike 726:
1.1 mike 727:
728:
1.1030 mike 729: <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 730: <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 731:
732: <dd>Append a submenu to the menu, using the value of the element's
733: <code title="">label</code> attribute as the label of the menu. The
734: submenu must be constructed by taking the element and creating a
735: new menu for it using the complete process described in this
736: section.</dd>
737:
738:
739: <dt>Any other node</dt>
740:
741: <dd><a href="infrastructure.html#ignore">Ignore</a> the node.</dd>
742:
743: </dl><p>Once all the nodes have been processed as described above, the
744: user agent must the post-process the menu as follows:</p>
745:
1.521 mike 746: <ol><li>Except for separators, any menu item with no label, or whose
747: label is the empty string, must be removed.</li>
1.1 mike 748:
1.521 mike 749: <li>Any sequence of two or more separators in a row must be
750: collapsed to a single separator.</li>
1.1 mike 751:
1.521 mike 752: <li>Any separator at the start or end of the menu must be
753: removed.</li>
1.1 mike 754:
1.1011 mike 755: </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 756: attribute gives the element's <a href="#context-menus" title="context menus">context
1.1030 mike 757: 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 758: in the DOM. <span class="impl">If the node that would be obtained by
1.875 mike 759: the invoking the <code title="dom-Document-getElementById"><a href="infrastructure.html#dom-document-getelementbyid">getElementById()</a></code> method
760: using the attribute's value as the only argument is null or not a
1.1030 mike 761: <code><a href="#the-menu-element">menu</a></code> element, then the element has no assigned context
1.1 mike 762: menu. Otherwise, the element's assigned context menu is the element
1.117 mike 763: so identified.</span></p><div class="impl">
1.1 mike 764:
765: <p>When an element's context menu is requested (e.g. by the user
1.1005 mike 766: right-clicking the element, or pressing a context menu key), the
767: user agent must apply the appropriate rules from the following
768: list:</p>
769:
770: <dl class="switch"><dt>If the user requested a context menu using a pointing device</dt>
771:
772: <dd><p>The user agent must dispatch an event with the name <code title="event-contextmenu">contextmenu</code>, that bubbles and is
1.1032 mike 773: cancelable, and that uses the <code><a href="infrastructure.html#mouseevent">MouseEvent</a></code> interface, at
1.1005 mike 774: the element for which the menu was requested. The context
775: information of the event must be set to the same values as the last
1.1032 mike 776: <code><a href="infrastructure.html#mouseevent">MouseEvent</a></code> user interaction event that was dispatched
1.1005 mike 777: as part of the gesture that that was interpreted as a request for
778: the context menu.</p></dd>
779:
780: <dt>Otherwise</dt>
781:
782: <dd><p>The user agent must <a href="webappapis.html#fire-a-synthetic-mouse-event" title="fire a synthetic mouse
783: event">fire a synthetic mouse event named <code title="event-contextmenu">contextmenu</code></a> that bubbles
784: and is cancelable at the element for which the menu was
785: requested.</p></dd>
1.1 mike 786:
1.1005 mike 787: </dl><p class="note">Typically, therefore, the firing of the <code title="event-contextmenu">contextmenu</code> event will be the
1.1 mike 788: default action of a <code title="mouseup">mouseup</code> or <code title="event-keyup">keyup</code> event. The exact sequence of events
789: is UA-dependent, as it will vary based on platform conventions.</p>
790:
791: <p>The default action of the <code title="event-contextmenu">contextmenu</code> event depends on
792: whether the element or one of its ancestors has a context menu
793: assigned (using the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> attribute) or not. If
794: there is no context menu assigned, the default action must be for
795: the user agent to show its default context menu, if it has one.</p>
796:
797: <p>If the element or one of its ancestors <em>does</em> have a
1.788 mike 798: context menu assigned, then the user agent must <a href="webappapis.html#fire-a-simple-event">fire a simple
1.454 mike 799: event</a> named <code title="event-show">show</code> at the
1.1030 mike 800: <code><a href="#the-menu-element">menu</a></code> element of the context menu of the nearest
1.1 mike 801: ancestor (including the element itself) with one assigned.</p>
1.1029 mike 802:
1.1 mike 803:
804: <p>The default action of <em>this</em> event is that the user agent
1.385 mike 805: must show a context menu <a href="#building-menus-and-toolbars" title="building menus and
1.1030 mike 806: toolbars">built</a> from the <code><a href="#the-menu-element">menu</a></code> element.</p>
1.1 mike 807:
808: <p>The user agent may also provide access to its default context
809: menu, if any, with the context menu shown. For example, it could
810: merge the menu items from the two menus together, or provide the
811: page's context menu as a submenu of the default menu.</p>
812:
813: <p>If the user dismisses the menu without making a selection,
814: nothing in particular happens.</p>
815:
1.987 mike 816: <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
817: that command's <a href="commands.html#command-facet-action" title="command-facet-Action">Action</a>.</p>
1.1 mike 818:
819: <p>Context menus must not, while being shown, reflect changes in the
1.521 mike 820: DOM; they are constructed as the default action of the <code title="event-show">show</code> event and must remain as constructed
821: until dismissed.</p>
1.1 mike 822:
823: <p>User agents may provide means for bypassing the context menu
824: processing model, ensuring that the user can always access the UA's
825: default context menus. For example, the user agent could handle
826: right-clicks that have the Shift key depressed in such a way that it
827: does not fire the <code title="event-contextmenu">contextmenu</code>
828: event and instead always shows the default context menu.</p>
829:
830: <p>The <dfn id="dom-contextmenu" title="dom-contextMenu"><code>contextMenu</code></dfn>
1.1024 mike 831: 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 832:
1.520 mike 833: </div><div class="example">
834:
835: <p>Here is an example of a context menu for an input control:</p>
836:
837: <pre><form name="npc">
838: <label>Character name: <input name=char type=text contextmenu=namemenu required></label>
839: <menu type=context id=namemenu>
840: <command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()">
841: <command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)">
842: </menu>
843: </form></pre>
844:
1.994 mike 845: <p>This adds two items to the control's context menu, one called
1.520 mike 846: "Pick random name", and one called "Prefill other fields based on
847: name". They invoke scripts that are not shown in the example
848: above.</p>
849:
1.117 mike 850: </div><div class="impl">
1.1 mike 851:
1.1011 mike 852: <h5 id="toolbars"><span class="secno">4.11.4.4 </span><dfn>Toolbars</dfn></h5>
1.1 mike 853:
1.1030 mike 854: <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 855: must <a href="#building-menus-and-toolbars" title="building menus and toolbars">build</a> the
1.1030 mike 856: menu for that <code><a href="#the-menu-element">menu</a></code> element, and use the result in the
1.1 mike 857: rendering.</p>
858:
859: <p>The user agent must reflect changes made to the
1.1030 mike 860: <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 861: and toolbars">rebuilding</a> the menu.</p>
1.1 mike 862:
1.117 mike 863: </div></body></html>
Webmaster