Search w3schools.com:

SHARE THIS PAGE

HTML contextmenu Attribute

HTML Global Attributes HTML Global Attributes

Example

Specify a context menu for a <p> element. The context menu should appear when a user right-clicks on the element:

<p contextmenu="supermenu">This paragraph has a context menu called "supermenu" attached.</p>

<menu id="supermenu">
  <command label="Step 1: Write Tutorial" onclick="doSomething()">
  <command label="Step 2: Edit Tutorial" onclick="doSomethingElse()">
</menu>

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The contextmenu attribute is not currently supported in any of the major browsers.


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.


Differences Between HTML 4.01 and HTML5

The contextmenu attribute is new in HTML5.


Syntax

<element contextmenu="menu_id">

Attribute Values

Value Description
menu_id The id of the <menu> element to open


HTML Global Attributes HTML Global Attributes

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]