<menuitem> - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:menuitem

Description

The <menuitem> element defines a menuitem.

Summary

Permitted Parent <menu>
Content None. It is an empty element.
Start/End TagStart tag: required, End tag: forbidden
Version New in HTML5

The example below shows the <menuitem> tag.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <script type="text/javascript">
  function zoomin(){<!--  w w w  .  ja  va 2  s  .c  om-->
    var myImg = document.getElementById("sky");
    var curr_width = myImg.clientWidth;
    myImg.style.width = (curr_width + 50) +"px";
  }
  function zoomout(){
    var myImg = document.getElementById("sky");
    var curr_width = myImg.clientWidth;
    myImg.style.width = (curr_width - 50) +"px";
  }
</script>
 </head>
 <body>
  <img src="https://www.java2s.com/style/demo/Opera.png" id="sky" width="250" contextmenu="skymenu">
  <menu type="context" id="skymenu">
   <menuitem label="Zoom In" onclick="zoomin()">
   <menuitem label="Zoom Out" onclick="zoomout()">
   <menuitem label="Reload Image" onclick="window.location.reload();">
  </menu>
 </body>
</html>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <menuitem> tag.

Attribute Require ValueDescription
label Required text name of the menu item, as shown to the user.
checkedOptional checked Boolean attribute sets if menu item is selected when the page loads.
commandOptional ID ID of a separate element, indicating a command to be invoked indirectly.
defaultOptional default Boolean attribute sets the menu item as default command.
disabled Optional disabled Boolean attribute sets if the menu item is disabled.
icon Optional URL an icon for the menu item.
radiogroup Optional group-name sets the name of a group of commands to be toggled as radio buttons when selected. Only be used where the type attribute is radio.
type Optional checkbox command radio sets the type of menu item. The default value of this attribute is command.

Related Tutorials