HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML contextmenu Attribute

HTML Global Attributes HTML Global Attributes

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

Internet Explorer Firefox Opera Google Chrome Safari

The contextmenu attribute is currently supported only in Firefox.


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]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE