{"id":2604,"date":"2015-03-06T13:15:29","date_gmt":"2015-03-06T11:15:29","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=2604"},"modified":"2018-06-20T15:53:45","modified_gmt":"2018-06-20T12:53:45","slug":"html5-navigation-bar-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/","title":{"rendered":"HTML5 Navigation Bar Example"},"content":{"rendered":"<p>In this article we will present you a way for creating an HTML5 navigation bar. We will only use CSS and no JavaScript. Let&#8217;s see how this can be done!<\/p>\n<p>[ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;]<\/p>\n<h2>1. The nav Tag<\/h2>\n<p>The <code>&lt;nav \/&gt;<\/code> Tag is one of the new elements introduced in the <a title=\"The HTML5 Specification\" href=\"http:\/\/www.w3.org\/TR\/html5\/sections.html#the-nav-element\" target=\"_blank\" rel=\"noopener\">HTML5 Specification<\/a>, this element represents a part of your document that contains links to parts of the page or to other pages.<\/p>\n<blockquote cite=\"http:\/\/www.w3.org\/TR\/html5\/sections.html#the-nav-element\"><p>A section with navigation links.<\/p><\/blockquote>\n<p>If the navigation links is a list of links, simply use the <code>&lt;ul\/&gt; &lt;li&gt;<\/code> tags to create the list, but as the specification say:<\/p>\n<blockquote cite=\"http:\/\/www.w3.org\/TR\/html5\/sections.html#the-nav-element\"><p>A <code>nav<\/code> element doesn&#8217;t have to contain a list, it can contain other kinds of content as well.<\/p><\/blockquote>\n<p>Let&#8217;s see an example.<\/p>\n<h3>1.1 Simple Navigation Example<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head lang=&quot;en&quot;&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;HTML5 Navigation Bar Example - Example 1&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;nav&gt;\r\n        &lt;ul&gt;\r\n            &lt;li&gt;&lt;a href=&quot;home.html&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;li&gt;&lt;a href=&quot;blog.html&quot;&gt;Blog&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;li&gt;&lt;a href=&quot;news.html&quot;&gt;News&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;\/ul&gt;\r\n    &lt;\/nav&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>As you can see it looks like any other lists :<\/p>\n<figure id=\"attachment_2606\" aria-describedby=\"caption-attachment-2606\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1.png\"><img decoding=\"async\" class=\"size-full wp-image-2606\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1.png\" alt=\"HTML 5 Navigation Bar Example 1\" width=\"800\" height=\"600\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1.png 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1-300x225.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-2606\" class=\"wp-caption-text\">HTML 5 Navigation Bar Example 1<\/figcaption><\/figure>\n<h3>1.2 Adding some CSS<\/h3>\n<p>As we want to create a navigation bar we will add some CSS to the page to present the list as a navigation bar.<\/p>\n<p>First of all we define the default body styling :<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\nbody{\r\n    margin: 0;\r\n    padding: 0;\r\n    font-size: 15px;\r\n}\r\n<\/pre>\n<p>Then we create the &#8220;navbar style&#8221; :<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\nnav {\r\n    background-color: #333;\r\n    margin: 0;\r\n    overflow: hidden;\r\n}\r\n<\/pre>\n<p>And now we can add some style to the list element :<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\nnav ul{\r\n    margin: 0;\r\n    padding: 0;\r\n}\r\nnav ul li {\r\n    \/* This allow us to arrange list items in a row, without using float *\/\r\n    display: inline-block;\r\n    list-style-type: none;\r\n}\r\n\r\n\/* Create a style for the first level items *\/\r\nnav &gt; ul &gt; li &gt; a {\r\n    color: #aaa;\r\n    background-color:#FF0;\r\n    display: block;\r\n    line-height: 2em;\r\n    padding: 0.5em 0.5em;\r\n    text-decoration: none;\r\n}\r\n<\/pre>\n<figure id=\"attachment_2605\" aria-describedby=\"caption-attachment-2605\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1-2.png\"><img decoding=\"async\" class=\"size-full wp-image-2605\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1-2.png\" alt=\"HTML5 Navigation Bar Example 1 bis\" width=\"800\" height=\"600\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1-2.png 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex1-2-300x225.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-2605\" class=\"wp-caption-text\">HTML5 Navigation Bar Example 1 bis<\/figcaption><\/figure>\n<h2>2. Adding sub level<\/h2>\n<p>Now we will add some sub menus to the navigation bar. Let&#8217;s see the HTML code :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head lang=&quot;en&quot;&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;HTML5 Navigation Bar Example - Example 1&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;nav&gt;\r\n    &lt;ul&gt;\r\n        &lt;li&gt;\r\n            &lt;a href=&quot;home.html&quot;&gt;Home&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li&gt;&lt;a href=&quot;presentation.html&quot;&gt;presentation&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;contact.html&quot;&gt;contact&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;blog.html&quot;&gt;Blog&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;\r\n            &lt;a href=&quot;shop.html&quot;&gt;shop&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li&gt;&lt;a href=&quot;candy.html&quot;&gt;candy&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;chocolate.html&quot;&gt;chocolate&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;icecream.html&quot;&gt;ice cream&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;news.html&quot;&gt;News&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n&lt;\/nav&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>If you try to display the navigation just now, this will not look as expected, we need to add some CSS to manage the submenus :<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\nnav li &gt; ul li{\r\n    display: block;\r\n}\r\n\r\nnav  li &gt; ul li a {\r\n    color: #111;\r\n    display: block;\r\n    line-height: 2em;\r\n    padding: 0.5em 2em;\r\n    text-decoration: none;\r\n}\r\n\r\n\/* Change the background color when mouse over items *\/\r\nnav li:hover {\r\n    background-color: #666;\r\n}\r\n\/* display the submenu on mouse over main menu item*\/\r\nnav li:hover &gt; ul{\r\n    position:absolute;\r\n    display : block;\r\n}\r\n<\/pre>\n<p>The pseudo selector <code>:hover<\/code> allow us to display submenus when the mouse is hover the main menu item.<\/p>\n<figure id=\"attachment_2607\" aria-describedby=\"caption-attachment-2607\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex2.png\"><img decoding=\"async\" class=\"size-full wp-image-2607\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex2.png\" alt=\"HTML 5 Navigation Bar Example 2\" width=\"800\" height=\"600\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex2.png 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex2-300x225.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-2607\" class=\"wp-caption-text\">HTML 5 Navigation Bar Example 2<\/figcaption><\/figure>\n<h2>3. Third level menu<\/h2>\n<p>Imagine now you want to create a third level menu, and we want it to be shown on the right of menu item.<\/p>\n<p>So we have to edit the HTML to add some submenu in one or more second level menu element&#8230;<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head lang=&quot;en&quot;&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;HTML5 Navigation Bar Example - Example 1&lt;\/title&gt;\r\n    &lt;link href=&quot;style3.css&quot; rel=&quot;stylesheet&quot;\/&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;nav&gt;\r\n    &lt;ul&gt;\r\n        &lt;li&gt;\r\n            &lt;a href=&quot;home.html&quot;&gt;Home&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li&gt;&lt;a href=&quot;presentation.html&quot;&gt;presentation&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;\r\n                    &lt;a href=&quot;contact.html&quot;&gt;contact&lt;\/a&gt;\r\n                    &lt;ul&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li&gt;\r\n            &lt;a href=&quot;blog.html&quot;&gt;Blog&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li&gt;\r\n            &lt;a href=&quot;shop.html&quot;&gt;Shop&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li&gt;\r\n                    &lt;a href=&quot;candy.html&quot;&gt;candy&lt;\/a&gt;\r\n                    &lt;ul&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;chocolate.html&quot;&gt;chocolate&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;\r\n                    &lt;a href=&quot;icecream.html&quot;&gt;ice cream&lt;\/a&gt;\r\n                    &lt;ul&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;news.html&quot;&gt;News&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n&lt;\/nav&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>And we also have to edit the CSS by adding the following code:<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\nnav li &gt; ul &gt; li ul  {\r\n    display: none;\r\n    background-color: #888;\r\n}\r\nnav li &gt; ul &gt; li:hover &gt; ul  {\r\n    position:absolute;\r\n    display : block;\r\n    margin-left:100%;\r\n    margin-top:-3em;\r\n}\r\n<\/pre>\n<p>This will create something like this &#8230;<\/p>\n<figure id=\"attachment_2608\" aria-describedby=\"caption-attachment-2608\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3.png\"><img decoding=\"async\" class=\"size-full wp-image-2608\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3.png\" alt=\"HTML 5 Navigation Bar Example 3\" width=\"800\" height=\"600\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3.png 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3-300x225.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-2608\" class=\"wp-caption-text\">HTML 5 Navigation Bar Example 3<\/figcaption><\/figure>\n<p>Without any modification if you add some submenus (in the third level one) you will have something like this :<\/p>\n<figure id=\"attachment_2609\" aria-describedby=\"caption-attachment-2609\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3-1.png\"><img decoding=\"async\" class=\"size-full wp-image-2609\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3-1.png\" alt=\"HTML 5 Navigation Bar Example 3 bis\" width=\"800\" height=\"600\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3-1.png 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex3-1-300x225.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-2609\" class=\"wp-caption-text\">HTML 5 Navigation Bar Example 3 bis<\/figcaption><\/figure>\n<p>Ok, now I would like to add some little icons to elements that have sub elements.<\/p>\n<h3>4. Drop down icon<\/h3>\n<p>In order to add some arrows to menu item (they will inform the user that the element contains a submenu), we will add a class <code>sub<\/code> to all those elements.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head lang=&quot;en&quot;&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;HTML5 Navigation Bar Example - Example 1&lt;\/title&gt;\r\n    &lt;link href=&quot;style4.css&quot; rel=&quot;stylesheet&quot;\/&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;nav&gt;\r\n    &lt;ul&gt;\r\n        &lt;li class=&quot;sub&quot;&gt;\r\n            &lt;a href=&quot;home.html&quot;&gt;Home&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li&gt;&lt;a href=&quot;presentation.html&quot;&gt;presentation&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li class=&quot;sub&quot;&gt;\r\n                    &lt;a href=&quot;contact.html&quot;&gt;contact&lt;\/a&gt;\r\n                    &lt;ul&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li class=&quot;sub&quot;&gt;\r\n                            &lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;\r\n                            &lt;ul&gt;\r\n                                &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                                &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                                &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n                            &lt;\/ul&gt;\r\n                        &lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li class=&quot;sub&quot;&gt;\r\n            &lt;a href=&quot;blog.html&quot;&gt;Blog&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li class=&quot;sub&quot;&gt;\r\n            &lt;a href=&quot;shop.html&quot;&gt;Shop&lt;\/a&gt;\r\n            &lt;ul&gt;\r\n                &lt;li class=&quot;sub&quot;&gt;\r\n                    &lt;a href=&quot;candy.html&quot;&gt;candy&lt;\/a&gt;\r\n                    &lt;ul&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li class=&quot;sub&quot;&gt;\r\n                            &lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;\r\n                            &lt;ul&gt;\r\n                                &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                                &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                                &lt;li class=&quot;sub&quot;&gt;\r\n                                    &lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;\r\n                                    &lt;ul&gt;\r\n                                        &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                                        &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                                        &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n                                    &lt;\/ul&gt;\r\n                                &lt;\/li&gt;\r\n                            &lt;\/ul&gt;\r\n                        &lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/li&gt;\r\n                &lt;li&gt;&lt;a href=&quot;chocolate.html&quot;&gt;chocolate&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;li class=&quot;sub&quot;&gt;\r\n                    &lt;a href=&quot;icecream.html&quot;&gt;ice cream&lt;\/a&gt;\r\n                    &lt;ul&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;one.html&quot;&gt;One&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;two.html&quot;&gt;Two&lt;\/a&gt;&lt;\/li&gt;\r\n                        &lt;li&gt;&lt;a href=&quot;three.html&quot;&gt;Three&lt;\/a&gt;&lt;\/li&gt;\r\n                    &lt;\/ul&gt;\r\n                &lt;\/li&gt;\r\n            &lt;\/ul&gt;\r\n        &lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;news.html&quot;&gt;News&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n&lt;\/nav&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>And in the CSS, we will add only two directives :<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\nnav ul &gt; li.sub{\r\n    background: url(ic_keyboard_arrow_down_white_18dp.png) right center no-repeat;\r\n}\r\n\r\nnav ul &gt; li.sub li.sub{\r\n    background: url(ic_keyboard_arrow_right_white_18dp.png) right center no-repeat;\r\n}\r\n<\/pre>\n<p>Images are from the <a href=\"http:\/\/www.google.com\/design\/spec\/resources\/sticker-sheets-icons.html#sticker-sheets-icons-components\">Google Design<\/a> page.<\/p>\n<p>This will create something like this :<\/p>\n<figure id=\"attachment_2610\" aria-describedby=\"caption-attachment-2610\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex4.png\"><img decoding=\"async\" class=\"size-full wp-image-2610\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex4.png\" alt=\"HTML 5 Navigation Bar Example 4\" width=\"800\" height=\"600\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex4.png 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/ex4-300x225.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-2610\" class=\"wp-caption-text\">HTML 5 Navigation Bar Example 4<\/figcaption><\/figure>\n<h2>5. Download<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/html5_navigation_bar_example.zip\"><strong>HTML5 Navigation Bar Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this article we will present you a way for creating an HTML5 navigation bar. We will only use CSS and no JavaScript. Let&#8217;s see how this can be done! [ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;] 1. The nav Tag The &lt;nav \/&gt; Tag is one of the new elements introduced in the HTML5 Specification, this element represents a &hellip;<\/p>\n","protected":false},"author":46,"featured_media":914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html5"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML5 Navigation Bar Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about html5 navigation bar? Check out our Example where we will present you a way for creating an HTML5 navigation bar with CSS &amp; no JS!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML5 Navigation Bar Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about html5 navigation bar? Check out our Example where we will present you a way for creating an HTML5 navigation bar with CSS &amp; no JS!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-06T11:15:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-20T12:53:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Remi Goyard\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mimiz33\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Remi Goyard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/\"},\"author\":{\"name\":\"Remi Goyard\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242\"},\"headline\":\"HTML5 Navigation Bar Example\",\"datePublished\":\"2015-03-06T11:15:29+00:00\",\"dateModified\":\"2018-06-20T12:53:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/\"},\"wordCount\":2217,\"commentCount\":17,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"articleSection\":[\"HTML5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/\",\"name\":\"HTML5 Navigation Bar Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"datePublished\":\"2015-03-06T11:15:29+00:00\",\"dateModified\":\"2018-06-20T12:53:45+00:00\",\"description\":\"Interested to learn about html5 navigation bar? Check out our Example where we will present you a way for creating an HTML5 navigation bar with CSS & no JS!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML5\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/html5\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML5 Navigation Bar Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242\",\"name\":\"Remi Goyard\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g\",\"caption\":\"Remi Goyard\"},\"description\":\"I'm a senior web architect. Passionated by new technologies, programming, devops tools, and agile methodologies. I really enjoy to coach, or teach, people who wants to learn programming, from beginners to skilled programmers. Involved in local developer communities, Java User Group, PHP User Group, or Javascript User Group, i like to share with others about experiences, news or business. Coding is FUN !\",\"sameAs\":[\"http:\/\/www.mimiz.fr\/\",\"http:\/\/fr.linkedin.com\/in\/remigoyard\/en\",\"https:\/\/x.com\/@mimiz33\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/remi-goyard\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML5 Navigation Bar Example - Web Code Geeks - 2026","description":"Interested to learn about html5 navigation bar? Check out our Example where we will present you a way for creating an HTML5 navigation bar with CSS & no JS!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/","og_locale":"en_US","og_type":"article","og_title":"HTML5 Navigation Bar Example - Web Code Geeks - 2026","og_description":"Interested to learn about html5 navigation bar? Check out our Example where we will present you a way for creating an HTML5 navigation bar with CSS & no JS!","og_url":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2015-03-06T11:15:29+00:00","article_modified_time":"2018-06-20T12:53:45+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","type":"image\/jpeg"}],"author":"Remi Goyard","twitter_card":"summary_large_image","twitter_creator":"@mimiz33","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Remi Goyard","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/"},"author":{"name":"Remi Goyard","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242"},"headline":"HTML5 Navigation Bar Example","datePublished":"2015-03-06T11:15:29+00:00","dateModified":"2018-06-20T12:53:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/"},"wordCount":2217,"commentCount":17,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","articleSection":["HTML5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/","url":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/","name":"HTML5 Navigation Bar Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","datePublished":"2015-03-06T11:15:29+00:00","dateModified":"2018-06-20T12:53:45+00:00","description":"Interested to learn about html5 navigation bar? Check out our Example where we will present you a way for creating an HTML5 navigation bar with CSS & no JS!","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-navigation-bar-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"HTML5","item":"https:\/\/www.webcodegeeks.com\/category\/html5\/"},{"@type":"ListItem","position":3,"name":"HTML5 Navigation Bar Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242","name":"Remi Goyard","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g","caption":"Remi Goyard"},"description":"I'm a senior web architect. Passionated by new technologies, programming, devops tools, and agile methodologies. I really enjoy to coach, or teach, people who wants to learn programming, from beginners to skilled programmers. Involved in local developer communities, Java User Group, PHP User Group, or Javascript User Group, i like to share with others about experiences, news or business. Coding is FUN !","sameAs":["http:\/\/www.mimiz.fr\/","http:\/\/fr.linkedin.com\/in\/remigoyard\/en","https:\/\/x.com\/@mimiz33"],"url":"https:\/\/www.webcodegeeks.com\/author\/remi-goyard\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=2604"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2604\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=2604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=2604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=2604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}