HTML contextmenu Attribute
Definition and Usage
The contextmenu attribute specifies a context menu for an element. The context menu appears when a user right-clicks on the element.
The value of the contextmenu attribute is the id of the <menu> element to open.
Applies to
The contextmenu attribute is part of the Global Attributes, and can be used on any HTML element.
Element | Attribute |
---|---|
All HTML elements | contextmenu |
Example
Example
Specify a context menu for a <div> element. The context menu appears when a user right-clicks on the element:
<div contextmenu="mymenu">
<menu type="context" id="mymenu">
<menuitem label="Refresh"></menuitem>
<menuitem label="Twitter"></menuitem>
</menu>
</div>
Try it Yourself »
Browser Support
Attribute | |||||
---|---|---|---|---|---|
contextmenu | Not supported | Not supported | Yes | Not supported | Not supported |