HTML contextmenu Attribute (original) (raw)

Last Updated : 30 Aug, 2024

**HTML contextmenu attribute is a global attribute that will be used to define a context-menu bar for an element. The value of the contextmenu attribute must be the same as the **id of the element.

So basically, A context menu seems upon user relations, such as when a user right-clicks on the element. As know HTML5 allows us to customize this menu. Here are some implementation examples, including nested menus.

**Note: HTML **contextmenu Attribute is **not supported in **HTML5.

**Syntax:

**Attribute Values: It contains the value _**menu_id_which represents the id of the element to be opened.

Examples of HTML contextmenu Attribute

**Example: HTML code below illustrates the use of **contextmenu attribute.

HTML `

HTML contextmenu attribute

GeeksforGeeks

HTML contextmenu attribute

        <p>A Computer Science Portal for Geeks</p>


        <menu type="context" id="geeks">
            <menu label="Share on...">
                <menuitem label="Twitter" 
                          onclick=

"window.open('//twitter.com/intent/tweet?text=' + window.location.href);">

    <p>A Computer Science Portal for Geeks</p>
    <hr>
    <p>Right click on green div and see the menuitem
</center>

`

**Output:

HTML contextmenu Attribute

HTML contextmenu Attribute

**Supported Browsers:

HTML contextmenu Attribute no longer supports any browsers.