HTML <menu> 標籤

實例

帶有兩個菜單按鈕 ("File" 和 "Edit") 的工具欄,每個按鈕都包含帶有一系列選項的下拉選單:

<menu type="toolbar">
 <li>
 <menu label="File">
 <button type="button" onclick="file_new()">New...</button>
 <button type="button" onclick="file_open()">Open...</button>
 <button type="button" onclick="file_save()">Save</button>
 </menu>
 </li>
 <li>
 <menu label="Edit">
 <button type="button" onclick="edit_cut()">Cut</button>
 <button type="button" onclick="edit_copy()">Copy</button>
 <button type="button" onclick="edit_paste()">Paste</button>
 </menu>
 </li>
</menu>

瀏覽器支援

IE Firefox Chrome Safari Opera

目前所有主流瀏覽器都不支援 <menu> 標籤。

定義和用法

<menu> 標籤定義命令的列表或菜單。

<menu> 標籤用於上下文菜單、工具欄以及用於列出表單控制元件和命令。

提示和註釋:

提示:請使用 CSS 來設定菜單列表的樣式!

HTML 4.01 與 HTML5 之間的差異

在 HTML 4.01 中已棄用 <menu> 元素。

在 HTML5 中重新定義了 <menu> 元素。

HTML 與 XHTML 之間的差異

在 HTML 4.01 中,menu 元素不被贊成使用。

在 XHTML 1.0 Strict DTD 中,menu 元素不被支援。

屬性

New: HTML5 中的新屬性。

屬性 描述
label text 規定菜單的可見標籤。
type
  • popup
  • toolbar
規定要顯示哪種菜單型別。

全域性屬性

<menu> 標籤支援 HTML 中的全域性屬性

事件屬性

<menu> 標籤支援 HTML 中的事件屬性

相關頁面

HTML DOM 參考手冊:Column 對像