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