Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<menu>

This translation is incomplete. Please help translate this article from English.

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

L'element HTML <menu> 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.

Nota d'ús: Els elements <menu> i <ul> representen una llista no ordenada d'ítems. La diferència clau es que <ul> conté principalment ítems per mostrar, mentre que <menu> està destinat a elements interactius

Notes: 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.")}}

Categories de contingut Contingut dinàmic. Additionally, if in the list menu state, palpable content. (list menu is the default state, unless the parent element is a <menu> in the context menu state.)
Contingut permès If the element is in the list menu state: flow content, or alternatively, zero or more occurrences of <li>, <script>, and <template>.
If the element is in the context menu state: zero or more occurrences, in any order, of <menu> (context menu state only), <menuitem>, <hr>, <script>, and <template>.
Omissió de l'etiqueta Cap, tant l'etiqueta inicial com l’etiqueta final són obligatòries
Elements pares permessos Qualsevol element que accepti contingut dinàmic.
Interfície DOM HTMLMenuElement

Atributs

Aquest element inclou els atributs globals.

label
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 <menu> in the context menu state.
type
This attribute indicates the kind of menu being declared, and can be one of two values.
  • context: The context menu state, which represents a group of commands activated through another element. This might be through the menu attribute of a <button>, or an element with a contextmenu attribute. When nesting <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 <menu> in the context menu state.

Exemples

Exemple 1

<!-- 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>

Resultat

Exemple 2

<!-- 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>

Resultat

Especificacions

Especificació Estat Comentaris
WHATWG HTML Living Standard
The definition of '<menu>' in that specification.
Living Standard  
HTML5.1
The definition of '<menu>' in that specification.
Working Draft Definició inicial

Compatibilitat amb navegadors

Característica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Suport bàsic ? Not supported[1] ? ? ?
Característica Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Suport bàsic ? Not supported[1] ? ? ?

[1] Gecko has some implementation, though it is not compatible to the specification. Vegeu error 1100749.

Vegeu també

Document Tags and Contributors

 Contributors to this page: llue
 Last updated by: llue,