HTML <menu> Tag
The <menu> tag in HTML is used to represent a group of commands that a user can perform or activate. It can be used for creating contextual menus, toolbars, or navigation menus on a webpage.
Example:
<menu>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</menu>
In the above example, we have a simple <menu> with three menu items - Home, About, and Contact.
Main attributes of the <menu> tag:
Attribute | Description |
---|---|
type | Specifies the type of commands that the menu contains. Possible values are context (for contextual menus), toolbar (for toolbars), and list (for navigation menus). |
label | Specifies a visible label for the menu. |
Usage of attributes:
The type
attribute is used to specify the type of the menu. For example, if you want to create a contextual menu, you can use the following:
<menu type="context">
<li>Edit</li>
<li>Delete</li>
</menu>
The label
attribute can be used to provide a visible label for the menu. For example:
<menu label="Main Menu">
<li>Home</li>
<li>About</li>
<li>Contact</li>
</menu>
Using the <menu>
tag and its attributes, you can create user-friendly menus on your webpage that are easily accessible and visually appealing.