aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/html/element/menu/index.html
blob: 7d0b236c412fad81822d3d0256319321271c6f6c (plain)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
title: <menu>
slug: Web/HTML/Element/menu
translation_of: Web/HTML/Element/menu
---
<p>{{HTMLRef}}{{SeeCompatTable}}</p>

<p><strong>HTML элемент <code>&lt;menu&gt;</code></strong> представляет группу команд, которые пользователь может выполнить или активировать. Он включает как меню-списки, которые могут отображаться в верхней части экрана, так и <a href="/en-US/docs/Web/HTML/Element/menu#Context_menu"> контекстные меню</a>, например, такие, что могут появиться под кнопкой после нажатия.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/Web/HTML/Content_categories">Категории контента</a></th>
   <td>
    <p><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Flow content</a>. If the element's children include at least one {{HTMLElement("li")}} element: <a href="/en-US/docs/Web/Guide/HTML/Content_categories#Palpable_content">Palpable content</a>.</p>
   </td>
  </tr>
  <tr>
   <th scope="row">Разрешённое содержимое</th>
   <td>
    <p>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")}}. (<em>list menu</em> is the default state, unless the parent element is a {{HTMLElement("menu")}} in the <em>context menu</em> state.)</p>

    <p>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")}}.</p>
   </td>
  </tr>
  <tr>
   <th scope="row">Пропуск тега</th>
   <td>{{No_Tag_Omission}}</td>
  </tr>
  <tr>
   <th scope="row">Разрешённые родительские элементы</th>
   <td>Любой элемент, который поддерживает <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">основной поток</a>.</td>
  </tr>
  <tr>
   <th scope="row">Implicit ARIA role</th>
   <td><code><a href="/en-US/docs/Web/Accessibility/ARIA/Roles/List_role">list</a></code></td>
  </tr>
  <tr>
   <th scope="row">Разрешённые роли ARIA</th>
   <td>{{ARIARole("directory")}}, {{ARIARole("group")}}, <code><a href="/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role">listbox</a></code>, {{ARIARole("menu")}}, {{ARIARole("menubar")}}, {{ARIARole("none")}}, {{ARIARole("presentation")}}, {{ARIARole("radiogroup")}}, {{ARIARole("tablist")}}, {{ARIARole("toolbar")}} или {{ARIARole("tree")}}</td>
  </tr>
  <tr>
   <th scope="row">DOM-интерфейс</th>
   <td>{{DOMxRef("HTMLMenuElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Атрибуты">Атрибуты</h2>

<p>К этому элементу применимы <a href="/en-US/docs/Web/HTML/Global_attributes">глобальные атрибуты</a>.</p>

<dl>
 <dt>{{HTMLAttrDef("label")}} {{Deprecated_inline}}</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> {{Deprecated_inline}} : Indicates the <em>popup menu</em> state, which represents a group of commands activated through another element. This might be as a button menu referenced by a {{HTMLAttrxRef("menu", "button")}} attribute of a {{HTMLElement("button")}} element, or as context menu for an element with a <a href="/en-US/docs/HTML/Global_attributes#attr-contextmenu"><code>contextmenu</code></a> attribute. This value is the default if the attribute is missing and the parent element is also a <code>&lt;menu&gt;</code> element.</li>
  <li><code>toolbar</code>: Indicates the <em>toolbar</em> state, which represents a toolbar consisting of a series of commands for user interaction. This might be in the form of an unordered list of {{HTMLElement("li")}} elements, or, if the element has no <code>&lt;li&gt;</code> element children, <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">flow content</a> describing available commands. This value is the default if the attribute is missing.</li>
 </ul>
 </dd>
</dl>

<h2 id="Примечания_по_использованию">Примечания по использованию</h2>

<p>The {{HTMLElement("menu")}} and {{HTMLElement("ul")}} elements both represent an unordered list of items. The key difference is that {{HTMLElement("ul")}} primarily contains items for display, whilst {{HTMLElement("menu")}} is intended for interactive items, to act on.</p>

<p>An HTML menu can be used to create context menus (typically activated by right-clicking another element) or toolbars.</p>

<p><strong>{{anch("Context menu", "Context menus</strong>")}} consist of a <code>&lt;menu&gt;</code> element which contains {{HTMLElement("menuitem")}} elements for each selectable option in the menu, <code>&lt;menu&gt;</code> elements for submenus within the menu, and {{HTMLElement("hr")}} elements for separator lines to break up the menu's content into sections. Context menus are then attached to the element they're activated from using either the associated element's {{HTMLAttrxRef("contextmenu")}} attribute or, for {{anch("Button menu", "button-activated menus")}} attached to {{HTMLElement("button")}} elements, the {{HTMLAttrxRef("menu", "button")}} attribute.</p>

<p><strong>{{anch("Toolbar", "Toolbar menus</strong>")}} consist of a <code>&lt;menu&gt;</code> element whose content is described in one of two ways: either as an unordered list of items represented by {{HTMLElement("li")}} elements (each representing a command or option the user can utilize), or (if there are no <code>&lt;li&gt;</code> elements), <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">flow content</a> describing the available commands and options.</p>

<p>This element was deprecated in HTML4, but reintroduced in HTML5.1 and the HTML living standard. This document describes the current Firefox implementation. Type 'list' is likely to change to 'toolbar' according to HTML5.1.</p>

<h2 id="Примеры">Примеры</h2>

<h3 id="Context_menu" name="Context_menu">Context menu</h3>

<p>{{Deprecated_header}}</p>

<h4 id="HTML">HTML</h4>

<pre class="brush: html;">&lt;!-- A &lt;div&gt; element with a context menu --&gt;
&lt;div contextmenu="popup-menu"&gt;
  Right-click to see the adjusted context menu
&lt;/div&gt;

&lt;menu type="context" id="popup-menu"&gt;
  &lt;menuitem&gt;Action&lt;/menuitem&gt;
  &lt;menuitem&gt;Another action&lt;/menuitem&gt;
  &lt;hr/&gt;
  &lt;menuitem&gt;Separated action&lt;/menuitem&gt;
&lt;/menu&gt;
</pre>

<h4 id="CSS">CSS</h4>

<pre class="brush: css;">div {
  width: 300px;
  height: 80px;
  background-color: lightgreen;
}
</pre>

<h4 id="Result">Result</h4>

<p>{{EmbedLiveSample("Context_menu", "100%", 80)}}</p>

<h3 id="Menu_button" name="Menu_button">Menu button</h3>

<div class="blockIndicator warning">
<p>Menu buttons haven't been implemented in any known browsers yet. The {{HTMLAttrxRef("type", "menu")}} attribute on the <code>&lt;menu&gt;</code> element is now obsolete.</p>
</div>

<div class="blockIndicator warning">
<p>{{HTMLElement("menuitem")}} element is obsolete.</p>
</div>

<h4 id="HTML_2">HTML</h4>

<pre class="brush: html;">&lt;!-- A button, which displays a menu when clicked. --&gt;
&lt;button type="menu" menu="popup-menu"&gt;
  Dropdown
&lt;/button&gt;

&lt;menu type="context" id="popup-menu"&gt;
  &lt;menuitem&gt;Action&lt;/menuitem&gt;
  &lt;menuitem&gt;Another action&lt;/menuitem&gt;
  &lt;hr/&gt;
  &lt;menuitem&gt;Separated action&lt;/menuitem&gt;
&lt;/menu&gt;
</pre>

<h4 id="Result_2">Result</h4>

<p>{{EmbedLiveSample("Menu_button", "100%", 50)}}</p>

<h3 id="Toolbar" name="Toolbar">Toolbar</h3>

<div class="blockIndicator warning">
<p>Toolbar menus haven't been implemented in any known browsers yet.</p>
</div>

<h4 id="HTML_3">HTML</h4>

<pre class="brush: html;">&lt;!-- A context menu for a simple editor,
   - containing two menu buttons. --&gt;
&lt;menu type="toolbar"&gt;
  &lt;li&gt;
    &lt;button type="menu" menu="file-menu"&gt;File&lt;/button&gt;
    &lt;menu type="context" id="file-menu"&gt;
      &lt;menuitem label="New..." onclick="newFile()"&gt;
      &lt;menuitem label="Save..." onclick="saveFile()"&gt;
    &lt;/menu&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;button type="menu" menu="edit-menu"&gt;Edit&lt;/button&gt;
    &lt;menu type="context" id="edit-menu"&gt;
      &lt;menuitem label="Cut..." onclick="cutEdit()"&gt;
      &lt;menuitem label="Copy..." onclick="copyEdit()"&gt;
      &lt;menuitem label="Paste..." onclick="pasteEdit()"&gt;
    &lt;/menu&gt;
  &lt;/li&gt;
&lt;/menu&gt;
</pre>

<h4 id="Result_3">Result</h4>

<p>{{EmbedLiveSample("Toolbar", "100%", 100)}}</p>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("HTML WHATWG", "grouping-content.html#the-menu-element", "&lt;menu&gt;")}}</td>
   <td>{{Spec2("HTML WHATWG")}}</td>
   <td>No change from latest snapshot, {{SpecName("HTML5.3")}}</td>
  </tr>
  <tr>
   <td>{{SpecName("HTML5.1", "interactive-elements.html#the-menu-element", "&lt;menu&gt;")}}</td>
   <td>{{Spec2("HTML5.1")}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("html.elements.menu")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>Other list-related HTML Elements: {{HTMLElement("ol")}}, {{HTMLElement("ul")}}, {{HTMLElement("li")}}, {{HTMLElement("hr")}}, and the obsolete {{HTMLElement("dir")}}.</li>
 <li>The <a href="/en-US/docs/Web/HTML/Global_attributes#attr-contextmenu"><code>contextmenu</code></a> <a href="/en-US/docs/Web/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 {{HTMLAttrxRef("type", "menu", 'type="context"')}}.</li>
</ul>