html tutorial - contextmenu Attribute in HTML - html5 - html code - html form




Contextmenu attribute in html

Learn html - html tutorial - Contextmenu attribute in html - html examples - html programs

  • The contextmenu attribute defines a context menu for an element.
  • The context menu occurs when a user right-clicks on the element.
  • The contextmenu attribute value is the id of the <menu> tag to open.
  • The contextmenu attribute is section of the Global Attributes.

Syntax for contextmenu attribute:

<element contextmenu = “menu_id”>

Differences between HTML 4.01 and HTML5 for contextmenu attribute:

HTML 4.01

  • The contextmenu attribute has not been defined.

HTML5

  • HTML 5 support contextmenu attribute.

Applies to:

Elements Attribute
All HTML Elements contextmenu

Attribute Values:

Value HTML 4.0.1 HTML 5 Description
menu_id No yes Specifies the <menu> tag id to open

Sample coding for contextmenu attribute:

Tryit<!DOCTYPE html>
<html>
    <body>
        <div style="background:cyan;border:1px solid #ffffff;padding: 20px;" 
             contextmenu="wikitechy">
            <p>To see the context menu, right-click inside this box</p>
            <menu type="context" id="wikitechy">
                <menuitem label="Wikitechy" 
                          onclick="window.open('http://www.wikitechy.com?text=' + 
                                   window.location.href);"
                          icon="https://www.wikitechy.com/images/logo.png">
                </menuitem>
            </menu>
    </body>
</html>

Code Explanation for contextmenu attribute:

contextmenu Attribute Code Explanation

  1. contextmenu attribute used to add a specific context menu to the browser.
  2. id attribute of <menu> tag will be used by the contextmenu attribute.

Sample Output for contextmenu attribute:

contextmenu Attribute Output

  1. The output shows the context menu as “wikitechy”.

Browser Support for contextmenu attribute:

No No Yes No No

Tips and Notes

  • The context menu attribute is only supported in Firefox.

Related Searches to contextmenu Attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×