Summary -

In this topic, we described about the <menu> tag along with detailed example.

The <menuitem> tag is new in HTML5. Specifying the command or menuitem that user can invoke from a popup menu. <menuitem> tag is used to specify the command or menuitem that user can invoke from a popup menu.

The tag can be specified like <menuitem></menuitem>. A <menu> tag can contain more than one <menuitem> elements.

Syntax -

<menuitem>.. text here.. </menuitem>

Required Attributes -

AttributeDescriptionValues
LabelSpecifies the name of the menu itemText

Optional Attributes -

AttributeDescriptionValues
checkedSpecifies the menu item should be checked when page loadsChecked
CommandSpecifies the menu item action behavior
DefaultSpecifies the menu item as being a defaultDefault
DisabledSpecifies the menu item should be disabledDisabled
IconSpecifies the icon of the menu itemURL
RadiogroupSpecifies the name of the group of commands.Specially for radioGroup name
TypeSpecifies the type of menu itemCheckboxCommand(default)radio

Example -

<!DOCTYPE html>
<html>
	<head>
		<title>Menu Tag example.. </title>	
	</head>
	<body>
	    <img id="myPic" src="img/india.gif" contextmenu="tcmenu" 
	    alt="India map" height="180" width="150" ><br>
	    <p>Right click on image to invoke the context menu. </p>

	    <menu type="context" id="tcmenu">
		   <menuitem label="Home" onclick="window.open
			('https://www.tutorialscampus.com');">
		   </menuitem>
		   <menu label="Tutorials">
			 <menuitem label="html" 
				onclick="window.open('html/index.htm');">
			 </menuitem>
			 <menuitem label="sap-abap" 
				onclick="window.open('sap-abap/index.htm');">
			 </menuitem>
		   </menu>
		   <menuitem label="Contact us"
			onclick="window.open('contact-us.php');">
		   </menuitem>
	    </menu>	
	</body>
</html>

Output -

India map

Right click on the image to invoke the context menu.

Note! Only supported in Firefox at time of writing.