title: How to make navbar active link colour change on different pages
body: <p>I'm a beginner here, I've got what I believe is a simple problem which I don't know how to solve. Basically i'm making a responsive website, my problem right now is that I can't make my navbar correctly responsive on the other parts of the websites besides my index.html (which works fine).</p>
  
  <p>I've used the code from w3schools in order to create my navbar.</p>
  
  <p><a href="https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_topnav" rel="nofollow noreferrer">https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_topnav</a></p>
  
  <p>As I said it works on my index file. But when I'm on my "news page" It doesn't work correctly. It rezises itself but it says Home on the navbar to the left. How do I make it so that it says news on the news page, starts off news and not the home page? (And for Contact, About aswell) Much thanks! Sorry if this was a stupid question. This is my first time trying to make a responsive website!</p>
  
  <p>Here is the code aswell (from the link at w3 schools):</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style&gt;
  body {margin:0;}
  
  .topnav {
    overflow: hidden;
    background-color: #333;
  }
  
  .topnav a {
    float: left;
    display: block;
    color: #f2f2f2;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 17px;
  }
  
  .topnav a:hover {
    background-color: #ddd;
    color: black;
  }
  
  .active {
    background-color: #4CAF50;
    color: white;
  }
  
  .topnav .icon {
    display: none;
  }
  
  @media screen and (max-width: 600px) {
    .topnav a:not(:first-child) {display: none;}
    .topnav a.icon {
      float: right;
      display: block;
    }
  }
  
  @media screen and (max-width: 600px) {
    .topnav.responsive {position: relative;}
    .topnav.responsive .icon {
      position: absolute;
      right: 0;
      top: 0;
    }
    .topnav.responsive a {
      float: none;
      display: block;
      text-align: left;
    }
  
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div class="topnav" id="myTopnav"&gt;
    &lt;a href="#home" class="active"&gt;Home&lt;/a&gt;
    &lt;a href="#news"&gt;News&lt;/a&gt;
    &lt;a href="#contact"&gt;Contact&lt;/a&gt;
    &lt;a href="#about"&gt;About&lt;/a&gt;
    &lt;a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()"&gt;&amp;#9776;&lt;/a&gt;
  &lt;/div&gt;
  
  &lt;div style="padding-left:16px"&gt;
    &lt;h2&gt;Responsive Topnav Example&lt;/h2&gt;
    &lt;p&gt;Resize the browser window to see how it works.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  function myFunction() {
      var x = document.getElementById("myTopnav");
      if (x.className === "topnav") {
          x.className += " responsive";
      } else {
          x.className = "topnav";
      }
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>