メインコンテンツへスキップ

menu要素


1.仕様

MENU要素は、
そのコンテンツで構成されるツールバーを、
項目の順序なしリストの形式で表します。

MENU - - (li)* +(%Scriptsupporting) -- a toolbar. (Normal elements.) [Flow|Palpablelimited] --

menu

ツールバー (a toolbar)

種類

通常要素

カテゴリ
  • フローコンテンツ
  • パルパブルコンテンツ(条件付き)

要素の子に少なくとも1つの li要素が含まれる場合は、パルパブルコンテンツ。

コンテンツモデル
0個以上の<li>要素 オプションでスクリプトをサポートする要素が混在

0個以上の<li>要素が配置できます。オプションで、スクリプトをサポートする要素を混在して配置できます。

スクリプトをサポートする要素に分類される要素は、<script>要素, <template>要素 です。

タグの省略

どちらのタグも省略できません。

コンテンツ属性

グローバル属性のみ

DOM インターフェイス
HTMLMenuElement
  1. [Exposed=Window]
  2. interface HTMLMenuElement : HTMLElement {
  3. lastReviewed;
  4. [HTMLConstructor] constructor();
  5.  
  6. // also has obsolete members
  7. };
HTMLElement
  1. [Exposed=Window]
  2. interface HTMLElement : Element {
  3. [HTMLConstructor] constructor();
  4.  
  5. // metadata attributes
  6. [CEReactions] attribute DOMString title;
  7. [CEReactions] attribute DOMString lang;
  8. [CEReactions] attribute boolean translate;
  9. [CEReactions] attribute DOMString dir;
  10.  
  11. // user interaction
  12. [CEReactions] attribute (boolean or unrestricted double or DOMString)? hidden;
  13. [CEReactions] attribute DOMString inert;
  14. undefined click();
  15. [CEReactions] attribute DOMString accessKey;
  16. readonly attribute DOMString accessKeyLabel;
  17. [CEReactions] attribute boolean draggable;
  18. [CEReactions] attribute boolean spellcheck;
  19. [CEReactions] attribute DOMString writingSuggestions;
  20. [CEReactions] attribute DOMString autocapitalize;
  21.  
  22. [CEReactions] attribute [LegacyNullToEmptyString] DOMString innerText;
  23. [CEReactions] attribute [LegacyNullToEmptyString] DOMString outerText;
  24.  
  25. ElementInternals attachInternals();
  26.  
  27. // The popover API
  28. undefined showPopover();
  29. undefined hidePopover();
  30. boolean togglePopover(optional boolean force);
  31. [CEReactions] attribute DOMString? popover;
  32. };
  33.  
  34. HTMLElement includes GlobalEventHandlers;
  35. HTMLElement includes ElementContentEditable;
  36. HTMLElement includes HTMLOrSVGElement;
Element
  1. [Exposed=Window]
  2. interface Element : Node {
  3. readonly attribute DOMString? namespaceURI;
  4. readonly attribute DOMString? prefix;
  5. readonly attribute DOMString localName;
  6. readonly attribute DOMString tagName;
  7.  
  8. [CEReactions] attribute DOMString id;
  9. [CEReactions] attribute DOMString className;
  10. [SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
  11. [CEReactions, Unscopable] attribute DOMString slot;
  12.  
  13. boolean hasAttributes();
  14. [SameObject] readonly attribute NamedNodeMap attributes;
  15. sequence<DOMString> getAttributeNames();
  16. DOMString? getAttribute(DOMString qualifiedName);
  17. DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
  18. [CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
  19. [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
  20. [CEReactions] undefined removeAttribute(DOMString qualifiedName);
  21. [CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
  22. [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
  23. boolean hasAttribute(DOMString qualifiedName);
  24. boolean hasAttributeNS(DOMString? namespace, DOMString localName);
  25.  
  26. Attr? getAttributeNode(DOMString qualifiedName);
  27. Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
  28. [CEReactions] Attr? setAttributeNode(Attr attr);
  29. [CEReactions] Attr? setAttributeNodeNS(Attr attr);
  30. [CEReactions] Attr removeAttributeNode(Attr attr);
  31.  
  32. ShadowRoot attachShadow(ShadowRootInit init);
  33. readonly attribute ShadowRoot? shadowRoot;
  34.  
  35. Element? closest(DOMString selectors);
  36. boolean matches(DOMString selectors);
  37. boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches
  38.  
  39. HTMLCollection getElementsByTagName(DOMString qualifiedName);
  40. HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
  41. HTMLCollection getElementsByClassName(DOMString classNames);
  42.  
  43. [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
  44. undefined insertAdjacentText(DOMString where, DOMString data); // legacy
  45. };
GlobalEventHandlers
  1. interface mixin GlobalEventHandlers {
  2. attribute EventHandler onabort;
  3. attribute EventHandler onauxclick;
  4. attribute EventHandler onbeforeinput;
  5. attribute EventHandler onbeforematch;
  6. attribute EventHandler onbeforetoggle;
  7. attribute EventHandler onblur;
  8. attribute EventHandler oncancel;
  9. attribute EventHandler oncanplay;
  10. attribute EventHandler oncanplaythrough;
  11. attribute EventHandler onchange;
  12. attribute EventHandler onclick;
  13. attribute EventHandler onclose;
  14. attribute EventHandler oncontextlost;
  15. attribute EventHandler oncontextmenu;
  16. attribute EventHandler oncontextrestored;
  17. attribute EventHandler oncopy;
  18. attribute EventHandler oncuechange;
  19. attribute EventHandler oncut;
  20. attribute EventHandler ondblclick;
  21. attribute EventHandler ondrag;
  22. attribute EventHandler ondragend;
  23. attribute EventHandler ondragenter;
  24. attribute EventHandler ondragleave;
  25. attribute EventHandler ondragover;
  26. attribute EventHandler ondragstart;
  27. attribute EventHandler ondrop;
  28. attribute EventHandler ondurationchange;
  29. attribute EventHandler onemptied;
  30. attribute EventHandler onended;
  31. attribute OnErrorEventHandler onerror;
  32. attribute EventHandler onfocus;
  33. attribute EventHandler onformdata;
  34. attribute EventHandler oninput;
  35. attribute EventHandler oninvalid;
  36. attribute EventHandler onkeydown;
  37. attribute EventHandler onkeypress;
  38. attribute EventHandler onkeyup;
  39. attribute EventHandler onload;
  40. attribute EventHandler onloadeddata;
  41. attribute EventHandler onloadedmetadata;
  42. attribute EventHandler onloadstart;
  43. attribute EventHandler onmousedown;
  44. [LegacyLenientThis] attribute EventHandler onmouseenter;
  45. [LegacyLenientThis] attribute EventHandler onmouseleave;
  46. attribute EventHandler onmousemove;
  47. attribute EventHandler onmouseout;
  48. attribute EventHandler onmouseover;
  49. attribute EventHandler onmouseup;
  50. attribute EventHandler onpaste;
  51. attribute EventHandler onpause;
  52. attribute EventHandler onplay;
  53. attribute EventHandler onplaying;
  54. attribute EventHandler onprogress;
  55. attribute EventHandler onratechange;
  56. attribute EventHandler onreset;
  57. attribute EventHandler onresize;
  58. attribute EventHandler onscroll;
  59. attribute EventHandler onscrollend;
  60. attribute EventHandler onsecuritypolicyviolation;
  61. attribute EventHandler onseeked;
  62. attribute EventHandler onseeking;
  63. attribute EventHandler onselect;
  64. attribute EventHandler onslotchange;
  65. attribute EventHandler onstalled;
  66. attribute EventHandler onsubmit;
  67. attribute EventHandler onsuspend;
  68. attribute EventHandler ontimeupdate;
  69. attribute EventHandler ontoggle;
  70. attribute EventHandler onvolumechange;
  71. attribute EventHandler onwaiting;
  72. attribute EventHandler onwebkitanimationend;
  73. attribute EventHandler onwebkitanimationiteration;
  74. attribute EventHandler onwebkitanimationstart;
  75. attribute EventHandler onwebkittransitionend;
  76. attribute EventHandler onwheel;
  77. };
ElementContentEditable
  1. interface mixin ElementContentEditable {
  2. [CEReactions] attribute DOMString contentEditable;
  3. [CEReactions] attribute DOMString enterKeyHint;
  4. readonly attribute boolean isContentEditable;
  5. [CEReactions] attribute DOMString inputMode;
  6. };
HTMLOrSVGElement
  1. interface mixin HTMLOrSVGElement {
  2. [SameObject] readonly attribute DOMStringMap dataset;
  3. attribute DOMString nonce; // intentionally no [CEReactions]
  4.  
  5. [CEReactions] attribute boolean autofocus;
  6. [CEReactions] attribute long tabIndex;
  7. undefined focus(optional FocusOptions options = {});
  8. undefined blur();
  9. };
ARIA in HTML
暗黙的="list" ARIAロール="あり" aria-* 属性="GlobalAny"

暗黙的な ARIAセマンティクスは、role=list です。

作成者が要素に指定してもよい ARIAロール値は、 group, listbox, menu, menubar, none, presentation, radiogroup, tablist, toolbar, tree です。

グローバル aria-* 属性と、許可されたロールに適用される任意の aria-* 属性が記述できます。

レンダリング
ブロックボックス
リスト
  1. menu {
  2. display: block;
  3. margin-block: 1em;
  4. padding-inline-start: 40px;
  5. counter-reset: list-item;
  6. list-style-type: disc;
  7. unicode-bidi: isolate;
  8. }
  9. :is(dir, dl, menu, ol, ul) menu {
  10. margin-block: 0;
  11. }
  12. :is(dir, menu, ol, ul) menu {
  13. list-style-type: circle;
  14. }
  15. :is(dir, menu, ol, ul) :is(dir, menu, ol, ul) menu {
  16. list-style-type: square;
  17. }

CSS を大雑把に読むと、 ブロックレベルのブロックコンテナボックス(ブロックボックス)を生成します。 などになります。

説明
menu要素は、その内容で構成されるツールバーを表します。

menu要素は、コマンドの一覧(リスト・list)を表します。コマンドの順序は重要ではありません。つまり、順序を変更しても文書(ドキュメント・document)の意味は大きく変わりません。とはいえ、ul要素に対するol要素のような要素は menu要素には見当たりません。順序に意味のあるコマンドの一覧はどうするべきか悩みどころです。実際の処、ul要素を用いるのが無難です。順序に意味のあるコマンドの一覧は、ol要素を用いるのが無難です。
リストの項目は、menu要素の li要素の子ノードで、ツリー順になっています。

  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>menu要素の例 - (Example of menu element) | 離珠のHTMLでしぃ!</title>
  6. <meta name="author" content="コータン (KOUTAN)">
  7. <link rel="icon" href="../favicon.ico" type="image/vnd.microsoft.icon">
  8. </head>
  9. <body>
  10. <h1>menu要素の例</h1>
  11. <menu>
  12. <li>
  13. <button onclick="copy()">
  14. <img src="copy.svg" alt="Copy">
  15. </button>
  16. </li>
  17. <li>
  18. <button onclick="cut()">
  19. <img src="cut.svg" alt="Cut">
  20. </button>
  21. </li>
  22. <li>
  23. <button onclick="paste()">
  24. <img src="paste.svg" alt="Paste">
  25. </button>
  26. </li>
  27. </menu>
  28. <p>HTML Living Standard での例示をそのままで、スクリプトや画像は用意していない状態です。</p>
  29. <a style="word-break: break-all" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-menu-element" target="_top">https://html.spec.whatwg.org/multipage/grouping-content.html#the-menu-element</a>
  30. </body>
  31. </html>

このサンプルへのリンクです。
(./exmenu.htm)

JSONデータ
JSON形式での、データのイメージです。
  1. {
  2. "menu": {
  3. "group": "Lists",
  4. "element": "- - (li)* +(%Scriptsupporting) -- a toolbar. (Normal elements.) [Flow|Palpablelimited] --",
  5. "attlist": {"%Global;": ""},
  6. "summary": "ツールバー (a toolbar)",
  7. "point": "その内容で構成されるツールバーを表します。",
  8. "description": [
  9. "コマンドの一覧(リスト・list)を表します。コマンドの順序は重要ではありません。つまり、順序を変更しても文書(ドキュメント・document)の意味は大きく変わりません。とはいえ、ul要素に対するol要素のような要素は menu要素には見当たりません。順序に意味のあるコマンドの一覧はどうするべきか悩みどころです。実際の処、ul要素を用いるのが無難です。順序に意味のあるコマンドの一覧は、ol要素を用いるのが無難です。",
  10. "リストの項目は、menu要素の li要素の子ノードで、ツリー順になっています。",
  11. ],
  12. "elementKind": "Normal",
  13. "categories": [
  14. "Flow",
  15. "Palpablelimited",
  16. ],
  17. "categoriessupplement": "要素の子に少なくとも1つの li要素が含まれる場合は、パルパブルコンテンツ。",
  18. "canUsedContexts": "parent (%Flow)*",
  19. "contentModel": "menu (li)* +(%Scriptsupporting)",
  20. "tagOmission": [
  21. "-",
  22. "-",
  23. ],
  24. "rendering": [
  25. "Lists",
  26. "Bidirectional",
  27. ],
  28. "domInterface": "HTMLMenuElement",
  29. "contentAttributes": "Global",
  30. "reference": [
  31. {
  32. "title": "HTML Living Standard. 4.4.7 The menu element. Last Updated 29 August 2025",
  33. "href": "https://html.spec.whatwg.org/multipage/grouping-content.html#the-menu-element",
  34. "heading": "HTML Living Standard. 4.4.7 The menu element",
  35. "sub": "最終更新日 2025年8月29日",
  36. },
  37. {
  38. "title": "HTML Living Standard. 15 Rendering 15.3.7 Lists. Last Updated 29 August 2025",
  39. "href": "https://html.spec.whatwg.org/multipage/rendering.html#lists",
  40. "heading": "HTML Living Standard. 15 Rendering 15.3.7 Lists",
  41. "sub": "最終更新日 2025年8月29日",
  42. },
  43. {
  44. "title": "HTML 5.3 W3C Working Draft. 11.2. Non-conforming features. W3C First Public Working Draft, 14 December 2017",
  45. "href": "https://www.w3.org/TR/2017/WD-html53-20171214/obsolete.html#non-conforming-features",
  46. "heading": "HTML 5.3 W3C 初公開ワーキングドラフト. 11.2. Non-conforming features",
  47. "sub": "W3Cワーキングドラフト、2017年12月14日",
  48. },
  49. {
  50. "title": "HTML 5.2 W3C Recommendation. 11.2. Non-conforming features. W3C Recommendation, 14 December 2017.",
  51. "href": "https://www.w3.org/TR/2017/REC-html52-20171214/obsolete.html#non-conforming-features",
  52. "heading": "HTML 5.2 W3C 勧告. 11.2. Non-conforming features",
  53. "sub": "W3C勧告、2017年12月14日",
  54. },
  55. {
  56. "title": "HTML 5.1 W3C Recommendation. 4.11.3 The menu element. W3C Recommendation, 1 November 2016.",
  57. "href": "https://www.w3.org/TR/2016/REC-html51-20161101/interactive-elements.html#the-menu-element",
  58. "heading": "HTML 5.1 W3C 勧告. 4.11.3 The menu element",
  59. "sub": "W3C勧告、2016年11月1日",
  60. },
  61. {
  62. "title": "HTML 5.1 W3C Recommendation. 10.3.8. Lists. W3C Recommendation, 1 November 2016.",
  63. "href": "https://www.w3.org/TR/2016/REC-html51-20161101/rendering.html#section-lists",
  64. "heading": "HTML 5.1 W3C 勧告. 10.3.8. Lists",
  65. "sub": "W3C勧告、2016年11月1日",
  66. },
  67. {
  68. "title": "HTML 4.01 Specification W3C Recommendation. 10.4 The DIR and MENU elements. W3C Recommendation 24 December 1999.",
  69. "href": "https://www.w3.org/TR/html401/struct/lists.html#h-10.4",
  70. "heading": "HTML 4.01 Specification W3C 勧告. 10.4 The DIR and MENU elements",
  71. "sub": "W3C勧告1999年12月24日",
  72. },
  73. {
  74. "title": "HTML 3.2 Reference Specification. W3C Recommendation 14-Jan-1997.",
  75. "href": "https://www.w3.org/TR/2018/SPSD-html32-20180315/",
  76. "heading": "HTML 3.2 Reference Specification",
  77. "sub": "W3C勧告1997年1月14日",
  78. },
  79. {
  80. "title": "Hypertext Markup Language - 2.0. November 1995.",
  81. "href": "https://www.ietf.org/rfc/rfc1866.txt",
  82. "heading": "Hypertext Markup Language - 2.0",
  83. "sub": "November 1995",
  84. },
  85. {
  86. "title": "Hypertext Markup Language (HTML). June 1993.",
  87. "href": "https://www.w3.org/MarkUp/draft-ietf-iiir-html-01.txt",
  88. "heading": "Hypertext Markup Language (HTML)",
  89. "sub": "June 1993",
  90. },
  91. {
  92. "title": "MDN Web Docs. HTML <menu>: The Menu element.",
  93. "href": "https://developer.mozilla.org/ja/docs/Web/HTML/Element/menu",
  94. "heading": "<menu>: メニュー要素 - HTML: ハイパーテキストマークアップ言語 | MDN",
  95. },
  96. ],
  97. "version": {
  98. "first": "HTML",
  99. "latest": "HTML Living Standard",
  100. },
  101. "lastReviewed": "2025-08-31",
  102. "obsoleteAttributes": [
  103. "type",
  104. "label",
  105. "compact",
  106. ],
  107. }
  108. }

注意: 簡易に描画する為に、各項目の後ろに , を付与しています。JSON の形式では、末尾の項目の後には , は付けません。

最終確認日

2025-08-31


2.使用できるコンテキスト

menu要素は、
フローコンテンツを
受け入れる要素に
使用できます。

<menu>要素が使用できるコンテキスト(Context文脈)は、フローコンテンツを受け入れる要素コンテンツとしてです。

body
menu
  1. <body>
  2. <menu>
  3. <li>項目1</li>
  4. <li>項目2</li>
  5. </menu>
  6. </body>

<body>要素のコンテンツの一部として、フローコンテンツである<menu>要素を配置している例です。


3.コンテンツモデル

menu要素は、
li要素を
配置できます。

<menu>要素子や子孫としてどのようなコンテンツ(Content内容) が含まれなければならないかというと、0 以上の<li>要素およびスクリプトをサポートする要素です。

スクリプトをサポートする要素に分類される要素は、以下の各要素です。

menu
li
Flow
content
  1. <menu>
  2. <li><p>項目1</p></li>
  3. <li><p>項目2</p></li>
  4. </menu>

<menu>要素のコンテンツの一部として、<li>要素を配置している例です。


4.コンテンツ属性

menu要素は、
グローバル属性のみ、
配置できます。

<menu>要素に指定することができる属性は、グローバル属性のみです。


5.DOM インターフェイス

menu要素を、
直接表す
プロパティは
ありません。

<menu>要素を JavaScript などで操作するには、documentgetElementById()メソッドを用いてid属性で指定して、<menu>要素を取得する方法があります。この時に取得できる値の形式はHTMLMenuElement インターフェイスです。

他には、documentquerySelectorAll()メソッドを用いて要素セレクタmenuと指定して用いるとか、name属性があればdocumentgetElementsByName()メソッドを用いるとか、状況, 目的によりいろいろあります。

この例示の文字の色は、です。
  • menu要素の文字の色
  • menu要素の文字の色
    1. <form>
    2. この例示の文字の色は、<select onchange="document.getElementById('JMN501').style.color = this.value;">
    3. <option value="inherit">継承する</option>
    4. <option value="red"></option>
    5. <option value="blue"></option>
    6. </select>です。
    7. </form>
    8. <menu id="JMN501">
    9. <li>menu要素の文字の色</li>
    10. <li>menu要素の文字の色</li>
    11. </menu>

    <menu>要素id属性を指定して、そのid属性で要素を取得する例です。例示では、cssのcolorを選択して設定する処理としています。例示で動的に表示する為に、フォームの内容が変更された時に処理するコードとしています。


    6.アクセシビリティ

    menu要素の
    暗黙的な
    ARIAセマンティクスは
    list role
    (リスト項目要素を
    含むセクション。)
    です。

    <menu>要素暗黙的なARIAセマンティクスは、role="list" です。
    list role は、「リスト項目要素を含むセクション。」です。

    リストには、listitem role を持つ子要素が含まれます。

    作成者が<menu>要素に明示的に指定可能なARIA ロール(役割)は、group, listbox, menu, menubar, none, presentation, radiogroup, tablist, toolbar, tree です。

    ARIA の状態プロパティについては、すべての要素で使用できるグローバル aria-* 属性に加えて、上記のロールに応じて使用可能なaria-* 属性が許可されます。

    著者は非推奨のdirectoryロールを使用しないでください。


    7.レンダリング

    1. menu {
    2. display: block;
    3. margin-block: 1em;
    4. padding-inline-start: 40px;
    5. counter-reset: list-item;
    6. list-style-type: disc;
    7. unicode-bidi: isolate;
    8. }

    <menu>要素ユーザーエージェントレベルスタイルシートデフォルトでは、displayプロパティの値は block であり、ブロックレベルブロックコンテナボックス(ブロックボックス) を生成します。

    ブロックフォーマットコンテキストに参加して、ブロックフォーマットコンテキストを継承, 確立します。もし、インラインフォーマットコンテキストに参加するコンテンツのみを含む場合は、新しいインラインフォーマットコンテキストを確立します。次に、すべてのインラインコンテンツをラップするルートインラインボックスも生成します。

    list-style-type は、リスト項目要素のマーカーを設定します。disc は、塗りつぶされた円形です。

    unicode-bidi は、置換されない要素のレンダリングでの Bidirectional text(双方向テキスト) に於いての期待される仕様の様です。

    1. :is(dir, dl, menu, ol, ul) menu { margin-block: 0; }
    2. :is(dir, menu, ol, ul) menu { list-style-type: circle; }
    3. :is(dir, menu, ol, ul) :is(dir, menu, ol, ul) menu { list-style-type: square; }

    <menu>要素のレンダリングに関する部分を抜粋したものです。<menu>要素が関わる他の要素のレンダリングに関する部分は省いています。

    body要素ブロックフォーマット
    コンテキスト
    menu要素ブロック
    フォーマット
    コンテキスト
    (継続)
    li要素コンテンツ
    1. <body>
    2. <menu>
    3. <li>ブロックレベルのボックスのみの例。</li>
    4. <li>ブロックレベルのボックスのみの例。</li>
    5. </menu>
    6. </body>

    <body>要素が存在して、その中に<menu>要素が存在して、その中に<li>要素がある例です。

    <body>要素は、ブロックレベルブロックコンテナであるボックスを生成します。<body>要素ブロックフォーマットコンテキストに配置される為、ブロックフォーマットコンテキストを継承します。<body>要素は、ブロックレベルボックスを生成する<menu>要素などを配置します。

    <menu>要素は、ブロックコンテナボックスを生成します。<li>要素は、ブロックレベルボックスを生成します。この例ではブロックレベルボックスを生成する要素だけを配置しています。なので、ブロックフォーマットコンテキストを継続します。

    尚、この説明は各要素のレンダリングに関する指定が既定値での話で、個々にスタイルを指定した場合はこの限りではありません。


    8.気を付ける点

    レンダリング

    ユーザーエージェントなどがどの様に扱ってくれるかが、作成者の意図と合うかどうかが問題かと思います。どうせなら <menu>要素という要素がないものとして、<ul>要素または<ol>要素から選んだ方が制作意図を表し易いかもしれません。