contextmenu

The historical contextmenu attribute was intended to attach a custom menu to an element's context-menu action, usually a right-click. It is obsolete and not reliably supported.

What you will learn

Historical syntax

<!-- Historical example: do not use for new work. -->
<div contextmenu="file-menu">Document</div>
<menu id="file-menu" type="context">...</menu>

Browsers do not consistently implement this feature, so a page cannot depend on it to provide a menu. It can also conflict with the browser's own context menu and with touch or keyboard interaction.

Prefer explicit controls

For actions such as Rename or Delete, provide a visible button and show a menu from that button. A native button gives users a predictable focus target and can be operated without a mouse.

Related pages