Answers for "which html tag to put the navigation bar in"

5

html navigation bar

<!--Method 1: Using HTML5 Nav Tag-->
<nav>
	Thing1 |
  	Thing2 |
  	Thing3
</nav>

<!--Method 2: HTML5 + CSS3 with DIV element-->

<ul class="topnav">
  <li><a class="active" href="#">Thing 1</a></li>
  <li><a href="#">Page 1</a></li>
  <li><a href="#">Page 2</a></li>
  <li class="right" ><a href="#">Thing 2</a></li>
</ul>
<style>
	
  ul.topnav {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
    font-family: arial;
    text-align: left;
    width: 100%;
    position: sticky;
    top: 0;
  }
  ul.topnav li {float: left;}
  ul.topnav li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    float: left;
    font-size: 17px;
    border-right: 1px solid #bbb;
  }
  ul.topnav li a:hover:not(.active) {
      background-color: #ddd;
      color: black;
  }
  ul.topnav li a.active {
      background-color: #4CAF50;
  }
  ul.topnav li.right {
      float: right;
  }
  @media screen and (max-width: 720px) {
    ul.topnav li{
        width: 100%;
    }
    ul.topnav a{
        width: 100%;
    }
  }
</style>
Posted by: Guest on January-03-2021
0

how to make a navigation bar in html

<!-- HTML PART -->
<a class="active" href="#home">Home</a>
<a href="news.html">News</a>
<a href="contact.html">Contact</a><a href="about.html">About</a>


<!-- CSS PART -->

.topnav a {
    float: left;
    color: goldenrod;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 20px;
  }
  
  /* Change the color of links on hover */
  .topnav a:hover {
    background-color: rgb(221, 221, 221);
    color: black;
  }
  
  /* Add a color to the active/current link */
  .topnav a.active {
    background-color: red;
    color: goldenrod;
  }
Posted by: Guest on September-04-2021

Code answers related to "which html tag to put the navigation bar in"

Browse Popular Code Answers by Language