--- title:
context
: The context menu 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 contextmenu
attribute. When nesting {{HTMLElement("menu")}} elements directly within one another, this is the missing value default if the parent is already in this state.list
: The list menu 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 context menu state.<!-- 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>
{{EmbedLiveSample('Example_1', '', '', '', 'Web/HTML/Element/menu')}}
<!-- 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>
{{EmbedLiveSample('Example_2', '', '', '', 'Web/HTML/Element/menu')}}
Especificació | Estat | Comentaris |
---|---|---|
{{SpecName('HTML WHATWG', 'interactive-elements.html#the-menu-element', '<menu>')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5.1', 'interactive-elements.html#the-menu-element', '<menu>')}} | {{Spec2('HTML5.1')}} | Definició inicial |
{{CompatibilityTable}}
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | {{CompatUnknown}} | {{CompatNo}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Característica | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Suport bàsic | {{CompatUnknown}} | {{CompatNo}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] Gecko has some implementation, though it is not compatible to the specification. Vegeu error 1100749.
contextmenu
global attribute can be used on an element to refer to the id
of a menu
with the context
{{htmlattrxref("type","menu")}}.