{"id":2614,"date":"2020-10-26T04:05:23","date_gmt":"2020-10-26T09:05:23","guid":{"rendered":"https:\/\/cssnewbie.com\/?p=2614"},"modified":"2022-06-18T16:52:29","modified_gmt":"2022-06-18T16:52:29","slug":"how-to-add-navigation-bar-in-css","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/how-to-add-navigation-bar-in-css\/","title":{"rendered":"How To Add Navigation Bar in CSS"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-2615 size-large\" src=\"https:\/\/cssnewbie.com\/wp-content\/uploads\/2020\/10\/Dark-map-1024x683.jpg\" alt=\"How To Add Navigation Bar in CSS\" width=\"1024\" height=\"683\" \/><\/p>\n<p>A good website is the one that provides visitors easy and quick access to information. This can be achieved by simply adding a navigation bar on your website.<\/p>\n<p>What is a navigation bar? It is a part of GUI within your website that helps users to easily navigate various pages of your website. It contains links to other pages on your website.<\/p>\n<p>A website without a navigation bar makes it difficult to locate various pages within the website. Navigation bar helps you to easily find pages you need. It is very important to have a navigation bar that is easy to use and attractive.<\/p>\n<p>Are you looking for transforming your simple HTML navigation bar into an interesting one? Then adding CSS to your HTML code is the best way to change your simple HTML navigation bar to a <a href=\"https:\/\/bashooka.com\/coding\/css-navigation-menu-designs\/\">good-looking navigation bar<\/a>.<\/p>\n<p>In our tutorial we will create navigation bar using the &lt;ul&gt; and &lt;li&gt; elements as it requires standard HTML as a base.<\/p>\n<p>Here is how a good navigation bar is:<\/p>\n<ul>\n<li>Simple<\/li>\n<li>Easy to use<\/li>\n<li>Perceptible<\/li>\n<li>Helpful<\/li>\n<li>Consistent<\/li>\n<\/ul>\n<p>Some examples of Navigation Bar:<\/p>\n<ul>\n<li>Simple Navigation Bar<\/li>\n<li>Fixed Navigation Bar<\/li>\n<li>Sticky Navigation Bar<\/li>\n<li>Responsive Navigation Bar<\/li>\n<li>Navigation Bar With Active\/Current Navigation Link<\/li>\n<li>Navigation Bar With Right-Align Links<\/li>\n<li>Navigation Bar With Dropdown<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.bitdegree.org\/learn\/css-navigation-bar\">Navigation bar<\/a> is a significant part of your website which is placed on almost all webpages of your website. Navigation bars are usually placed horizontally at the top of your webpages. Sometimes it is also placed vertically on the left or right side of your webpage.<\/p>\n<p>There are mainly two types of navigation bar in CSS:<\/p>\n<ol>\n<li>CSS Horizontal Navigation Bar<\/li>\n<li>CSS Verticle Navigation Bar<\/li>\n<\/ol>\n<h3><strong>1.CSS Horizontal Navigation Bar<\/strong><\/h3>\n<p>A Horizontal Navigation Bar is placed at the top of the website. It is usually always placed before the main content of your webpage. The horizontal navigation bar can be created using inline and floating list items.<\/p>\n<p>Let us see an example of creating a horizontal navigation bar with &lt;ul&gt; and &lt;li&gt; tags, right text floating, and background color black.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;How to Add Horizontal Navigation Bar in CSS&lt;\/title&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n&lt;ul&gt;\n\u00a0 &lt;li&gt;&lt;a href=\"#aboutus\"&gt;About Us&lt;\/a&gt;&lt;\/li&gt;\n\u00a0 &lt;li&gt;&lt;a href=\"#contact\"&gt;Contact&lt;\/a&gt;&lt;\/li&gt;\n\u00a0 &lt;li&gt;&lt;a href=\"#services\"&gt;Services&lt;\/a&gt;&lt;\/li&gt;\n\u00a0 &lt;li&gt;&lt;a href=\"#home\"&gt;Home&lt;\/a&gt;&lt;\/li&gt;\n&lt;\/ul&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p><strong>CSS File will be as follows:<\/strong><\/p>\n<pre>#ul {\n  list-style-type: none;\n  margin: 0;\n  padding: 0;\n  overflow: hidden;\n  background-color: black;\n}<\/pre>\n<pre>#li {\n  float: right;\n}\n\n#li a {\n  display: block;\n  color: white;\n  text-align: center;\n  padding: 14px 16px;\n  text-decoration: none;\n}<\/pre>\n<p><strong>Here\u2019s how the output will be:<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-2618 size-full\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2020\/10\/NAVIGATION1.png\" alt=\"How To Add Navigation Bar in CSS\" width=\"650\" height=\"339\" \/><\/p>\n<h3><strong>2.CSS Vertical Navigation Bar<\/strong><\/h3>\n<p>A Vertical Navigation bar is placed on the right or left side of your webpage. Since it is placed at the side of your website it is also called Sidebar. A lot of websites use the vertical navigation bar on their webpages. Let us see an example to create a vertical navigation bar using &lt;ul&gt; and &lt;li&gt; tags, hover to display current page, and black background.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;\nHow to Add Horizontal Navigation Bar in CSS\n&lt;\/title&gt;\n\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;ul&gt;\n \u00a0&lt;li&gt;&lt;a href=\"#home\"&gt;Home&lt;\/a&gt;&lt;\/li&gt;\n \u00a0&lt;li&gt;&lt;a href=\"#servicees\"&gt;Services&lt;\/a&gt;&lt;\/li&gt;\n \u00a0&lt;li&gt;&lt;a href=\"#contact\"&gt;Contact&lt;\/a&gt;&lt;\/li&gt;\n \u00a0&lt;li&gt;&lt;a href=\"#aboutus\"&gt;About Us&lt;\/a&gt;&lt;\/li&gt;\n&lt;\/ul&gt;\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/pre>\n<p><strong>\u00a0<\/strong><strong>CSS File will be as follows:<\/strong><\/p>\n<pre>#ul {\n \u00a0list-style-type: none;\n \u00a0margin: 0;\n \u00a0padding: 0;\n \u00a0width: 200px;\n \u00a0background-color: black;\n}\n\n#li a {\n \u00a0display: block;\n \u00a0color: white;\n \u00a0padding: 8px 16px;\n \u00a0text-decoration: none;\n}\n#li a:hover {\n \u00a0background-color: #555;\n \u00a0color: white;\n}<\/pre>\n<p><strong>Here\u2019s how the output will look like:<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-2617 size-full\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2020\/10\/NAVIGATION2.png\" alt=\"How To Add Navigation Bar in CSS\" width=\"664\" height=\"332\" \/><\/p>\n<h3><strong>Conclusion<\/strong><\/h3>\n<p>In this tutorial, we learned how to add a navigation bar in CSS. We also learned what is horizontal navigation bar and vertical navigation bar in CSS and how to add them. In the above examples, we used an external CSS file to link CSS to HTML. You can do this in another by adding CSS code in your HTML file using the &lt;style&gt; tag.<\/p>\n<p>By the way if you are not that technical and don&#8217;t have engineering resources at\u00a0 your disposal. I would recommend to use standard website builders like square space and show it. If you are confused between the two, check out <a href=\"https:\/\/www.mehdiaoussiad.com\/blog\/squarespace-vs-showit\">Squarespace vs Showit<\/a> comparison to make a better buying decision.<\/p>\n<p>To learn such CSS techniques, subscribe to our <a href=\"http:\/\/www.cssnewbie.com\">blog<\/a>!<\/p>\n<p>To see how to add forms in CSS, visit our previous article!<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<\/p>\n<p>A good website is the one that provides visitors easy and quick access to information. This can be achieved by simply adding a navigation bar on your website.<\/p>\n<p>What is a navigation bar? It is a part of GUI within your [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/how-to-add-navigation-bar-in-css\/\" title=\"Click to read 'How To Add Navigation Bar in CSS'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[168],"tags":[306],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2614"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=2614"}],"version-history":[{"count":2,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2614\/revisions"}],"predecessor-version":[{"id":3444,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2614\/revisions\/3444"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=2614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=2614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=2614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}