HTML <menu> Tag

The HTML <menu> element represents a toolbar consisting of its contents, in the form of an unordered list of items (represented by li elements), each of which represents a command that the user can perform or activate.

The <menu> element is simply a semantic alternative to the <ul> element to express an unordered list of commands (typically known as a "toolbar").

The <menu> element is specified in the WHATWG HTML Living Specification, but not the W3C HTML5.2 specification.

Syntax

The <menu> tag is written as <menu></menu> with its contents inserted between the start and end tags. The type attribute can be used to specify the type of menu being declared.

The <menu> element can contain zero or more <li> elements, which could potentially contain other <menu> elements.

Like this:

Example

Here's an example of using the <menu> tag to create a toolbar.

As mentioned, it simply creates semantic alternative to the <ul> element, so any styling to the toolbar should be done using CSS, and you can use a scripting language such as JavaScript or JQuery to perform the applicable action for each menu item.

Attributes

Attributes can be added to an HTML element to provide more information about how the element should appear or behave.

The <menu> element accepts the following attributes.

AttributeDescription
None

Global Attributes

The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <menu> tag , as well as with all other HTML tags.

For a full explanation of these attributes, see HTML 5 global attributes.

Event Handlers

Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.

Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.

For more detail, see HTML event handler content attributes.