HTML contextmenu Attribute

Example

Specifies the context menu of the <div> element. The context menu will appear when the 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

IE Firefox Chrome Safari Opera

Currently only Firefox supports the contextmenu attribute.

Definition and Usage

The contextmenu attribute specifies the context menu of the element. A context menu will appear when the user right-clicks on the element.

The value of the contextmenu attribute is the id of the <menu> element to be opened.

Differences between HTML 4.01 and HTML5

The contextmenu attribute is a new attribute in HTML5.

Syntax

<element contextmenu="menu_id">

Attribute Value

Value Description
menu_id The id of the <menu> element to be opened.