Difference between <nav> and <menu> tag in HTML5
β<nav>β Tag: The <nav> tag is used to specify navigation links either within the same document or any other document which means it provides link to contents which are either on same or different page/document.
Example:
<!DOCTYPE html> < html > < body > < h1 >The nav element</ h1 > < p >The nav element defines navigation links:</ p > < nav > < a href=β/home/β>HOME</ a > | < a href=β/category/β>CATEGORY</ a > | < a href=β/profile/β>PROFILE</ a > | </ nav > </ body > </ html > |
Output:
Example:
<!DOCTYPE html> < html > < head > < title >nav tag</ title > < style > nav { border:2px; background-color:#090; color:white; padding:8px; } a { color:white; font-size:25px; } .gfg { font-size:30px; color:#090; font-weight:bold; text-align:center; } .nav_tag { text-align:center; } </ style > </ head > < body > < div class = "gfg" >GFG</ div > < div class = "nav_tag" >Nav Element Example</ div > < nav > < a href = Home</ a > | < a href = Difference Between</ a > | < a href = Interview</ a > | < a href = Courses</ a > | </ nav > </ body > </ html > |
Output:
<menu> Tag: The <menu> tag in HTML is used for creating menu lists. It defines a list of commands which can be used by the users to create listing form control, toolbar, context menus, and commands. The <menu> tag was removed from HTML and reintroduced in HTML5. It is not supported on the majority of platforms.
Contents of βmenuβ tags:
- <menuitem>
- <li>
- <script>
- <hr>
Example:
<!DOCTYPE html> < html > < head > < title >HTML menu Tag</ title > </ head > < body > < p >menu tag</ p > < menu > < ol > < li >menu list</ li > < li >unordered list</ li > < li >ordered list</ li > </ ol > </ menu > </ body > </ html > |
Output:
Example:
<!DOCTYPE html> < html > < head > < title >html menu tag</ title > </ head > < body > < div style="background:#090;border:2px solid #cccccc;padding: 10px;" contextmenu = "testmenu" > < p > Right-click inside this box to view the context menu! </ p > < menu type = "context" id = "testmenu" > < menuitem label = "Refresh" onclick = "window.location.reload();" icon = "ico_reload.png" > </ menuitem > < menuitem label = "Email" onclick = "window.location='mailto:?body='+window.location.href;" > </ menuitem > </ menu > </ div > < p > This example currently works in Mozilla Firefox web browser please use Mozilla Firefox to view this example. </ p > </ body > </ html > |
Output:
S. No. | βnav tagβ | βmenu tagβ |
---|---|---|
1. | Syntax : <nav> </nav> | Syntax : <menu> </menu> |
2. | The β<nav>β tag creates navigation block which provides link for contents either on the same document/page or any other document/page. | The β<menu>β tag creates a list or menu of commands which can be utilized by the users. |
3. | The β<nav>β tag is introduced in HTML5. | It was deprecated in HTML 4.01 and reintroduced in HTML5. |
4. | It is highly compatible and supports most platforms. | It does not have much compatibility. |
5. | The β<nav>β tag is specifically for grouping elements in a Website. | The β<menu>β tag is for Web Applications to handle/design interactive elements. |
6. | The contents of nav tag are β<a href=β β>β, β<ul>β, β<ol>β and β<li>β etc. | The contents of menu tag are β<menu>β, β<menuitem>β, β<li>β, β<hr>β and β<script>β etc. |
7. | It is supported by majority of browsers. | It is not supported by most of the browsers. |
8. | Examples of browser support: Google Chrome, Microsoft Edge, Safari, Opera Browser, Mozilla Firefox. | Only Mozilla Firefox version 8 supports menu element of HTML5. |
Contact Us