Annotation of html5/spec/interactive-elements.html, revision 1.1025

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

Webmaster