Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML <menu> type Attribute

  • Last Updated : 14 Nov, 2021

The type attribute in <menu> element is used to define the type of menu bar. It is also used with the <menuitem> tag which defines the type of commands of the menu items. 

Syntax:

<menu type="list|context|toolbar">

Attribute values: 

  • list: It has a default value. It defines a list of menus that performs some actions when interacting with the user.
  • context: It defines a context menu that will perform an action before interacting with the user.
  • toolbar: It defines a toolbar menu that allows commands, allows the user to interact with the commands immediately.

Example: Below HTML code demonstrates the HTML <menu> type attribute.  

HTML




<!DOCTYPE html>
<html>
    
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
            
        <h2>HTML <menu> type attribute</h2>
            
        <div style="background:green;
                    border:2px solid black;
                    padding: 10px;" 
             contextmenu="geeks">
            <p>A Computer Science Portal for Geeks</p>
  
            <menu type="context" id="menuID">
                
                <menu label="Share on...">
                    <menuitem label="Twitter" 
                              onclick=
"window.open('//twitter.com/intent/tweet?text='+ window.location.href);">
                    </menuitem>
                    <menuitem label="Pinterest" onclick=
                    "window.open(
                        window.location.href);">
                    </menuitem>
                </menu>
    
                <menuitem label="Email This Page" 
                    onclick="window.location='mailto:?body='
                    + window.location.href;">
                </menuitem>
            </menu>
        </div>
    
        <p>A Computer Science Portal for Geeks</p>
  
        <hr>
        <p>Right click on green div and see the menuitem
    </center>
</body>
    
</html>

Output: 

HTML menu type attribute

Supported Browsers 

  • Firefox 8.0


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!