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