1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
---
title: <menu>
slug: Web/HTML/Element/menu
translation_of: Web/HTML/Element/menu
---
<div>{{HTMLRef}}{{SeeCompatTable}}</div>
<p>L'<strong>element</strong> <strong>HTML <code><menu></code></strong> representa un grup d'ordres que l'usuari pot realitzar o activar. Això inclou tant llistes com menús, que poden aparèixer a la part de dalt de la pantalla, com també menús de context, com les que poden aparèixer sota d'un botó després d'haver fet click.</p>
<div class="note"><strong>Nota d'ús: </strong>Els elements {{HTMLElement("menu")}} i {{HTMLElement("ul")}} representen una llista no ordenada d'ítems. La diferència clau es que {{HTMLElement("ul")}} conté principalment ítems per mostrar, mentre que {{HTMLElement("menu")}} està destinat a elements interactius</div>
<p class="note"><strong>Notes: </strong>This element was deprecated in HTML4, però reintroduit en l'HTML5.1 (still working draft).")}}. This document describes current Firefox implementation. Type 'list' is likely to change to 'toolbar' and 'context' to 'popup' according to HTML5.1 working draft.")}}</p>
<table class="properties">
<tbody>
<tr>
<th scope="row"><a href="/en-US/docs/Web/HTML/Content_categories">Categories de contingut</a></th>
<td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Contingut dinàmic</a>. Additionally, if in the <em>list menu</em> state, palpable content. (<em>list menu</em> is the default state, unless the parent element is a {{HTMLElement("menu")}} in the <em>context menu</em> state.)</td>
</tr>
<tr>
<th scope="row">Contingut permès</th>
<td>If the element is in the <em>list menu</em> state: <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">flow content</a>, or alternatively, zero or more occurrences of {{HTMLElement("li")}}, {{HTMLElement("script")}}, and {{HTMLElement("template")}}.<br>
If the element is in the <em>context menu</em> state: zero or more occurrences, in any order, of {{HTMLElement("menu")}} (<em>context menu</em> state only), {{HTMLElement("menuitem")}}, {{HTMLElement("hr")}}, {{HTMLElement("script")}}, and {{HTMLElement("template")}}.</td>
</tr>
<tr>
<th scope="row">Omissió de l'etiqueta</th>
<td>{{no_tag_omission}}</td>
</tr>
<tr>
<th scope="row">Elements pares permessos</th>
<td>Qualsevol element que accepti <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">contingut dinàmic</a>.</td>
</tr>
<tr>
<th scope="row">Interfície DOM</th>
<td>{{domxref("HTMLMenuElement")}}</td>
</tr>
</tbody>
</table>
<h2 id="Atributs">Atributs</h2>
<p>Aquest element inclou els <a href="/en-US/docs/Web/HTML/Global_attributes">atributs globals</a>.</p>
<dl>
<dt>{{htmlattrdef("label")}}</dt>
<dd>The name of the menu as shown to the user. Used within nested menus, to provide a label through which the submenu can be accessed. Must only be specified when the parent element is a {{HTMLElement("menu")}} in the <em>context menu</em> state.</dd>
<dt>{{htmlattrdef("type")}}</dt>
<dd>This attribute indicates the kind of menu being declared, and can be one of two values.
<ul>
<li><code>context</code>: The <em>context menu</em> state, which represents a group of commands activated through another element. This might be through the {{htmlattrxref("menu", "button")}} attribute of a {{HTMLElement("button")}}, or an element with a <a href="/en-US/docs/HTML/Global_attributes#attr-contextmenu"><code>contextmenu</code></a> attribute. When nesting {{HTMLElement("menu")}} elements directly within one another, this is the missing value default if the parent is already in this state.</li>
<li><code>list</code>: The <em>list menu</em> state, which represents a series of commands for user interaction. This is the missing value default, except where the parent element is a {{HTMLElement("menu")}} in the <em>context menu</em> state.</li>
</ul>
</dd>
</dl>
<h2 id="Exemples">Exemples</h2>
<h3 id="Exemple_1">Exemple 1</h3>
<pre class="brush: html"><!-- Un botó, que mostra un menú quan es clica -->
<button type="menu" menu="dropdown-menu">
Dropdown
</button>
<menu type="context" id="dropdown-menu">
<menuitem label="Action">
<menuitem label="Another action">
<hr>
<menuitem label="Separated action">
</menu>
</pre>
<h3 id="Resultat">Resultat</h3>
<p>{{EmbedLiveSample('Example_1', '', '', '', 'Web/HTML/Element/menu')}}</p>
<h3 id="Exemple_2">Exemple 2</h3>
<pre class="brush: html"><!-- un menú de context per a un simple editor, que conté dos botons de menú -->
<menu>
<li>
<button type="menu" value="File" menu="file-menu">
<menu type="context" id="file-menu">
<menuitem label="New..." onclick="newFile()">
<menuitem label="Save..." onclick="saveFile()">
</menu>
</li>
<li>
<button type="menu" value="Edit" menu="edit-menu">
<menu type="context" id="edit-menu">
<menuitem label="Cut..." onclick="cutEdit()">
<menuitem label="Copy..." onclick="copyEdit()">
<menuitem label="Paste..." onclick="pasteEdit()">
</menu>
</li>
</menu>
</pre>
<h3 id="Resultat_2">Resultat</h3>
<p>{{EmbedLiveSample('Example_2', '', '', '', 'Web/HTML/Element/menu')}}</p>
<h2 id="Especificacions">Especificacions</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Especificació</th>
<th scope="col">Estat</th>
<th scope="col">Comentaris</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', 'interactive-elements.html#the-menu-element', '<menu>')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('HTML5.1', 'interactive-elements.html#the-menu-element', '<menu>')}}</td>
<td>{{Spec2('HTML5.1')}}</td>
<td>Definició inicial</td>
</tr>
</tbody>
</table>
<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Característica</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Suport bàsic</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatNo}}<sup>[1]</sup></td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Característica</th>
<th>Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Suport bàsic</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatNo}}<sup>[1]</sup></td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<p>[1] Gecko has some implementation, though it is not compatible to the specification. Vegeu <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1100749">error 1100749</a>.</p>
<h2 id="Vegeu_també">Vegeu també</h2>
<ul>
<li>Other list-related HTML Elements: {{HTMLElement("ol")}}, {{HTMLElement("ul")}}, {{HTMLElement("li")}} and the obsolete {{HTMLElement("dir")}}.</li>
<li>The <a href="/en-US/docs/HTML/Global_attributes#attr-contextmenu"><code>contextmenu</code></a> <a href="/en-US/docs/HTML/Global_attributes">global attribute</a> can be used on an element to refer to the <code>id</code> of a <code>menu</code> with the <code>context</code> {{htmlattrxref("type","menu")}}.</li>
</ul>
|