How can I make the navigation menu get highlighted for the current page that I am visiting?
header.php
<div class="header-menu">
<div class="nav">
<ul>
<a href="index.php"><li>Home</li></a>
<a href=""><li>Register</li></a>
<a href="login.php"><li>Login</li></a>
<a href=""><li>FAQ</li></a>
<a href=""><li>Advertise</li></a>
<a href=""><li>Terms</li></a>
<a href=""><li>Support</li></a>
<a href=""><li>Forum</li></a>
</ul>
</div>
</div>
If I am currently on the login.php page, then in the navigation menu the login item should be highlighted (like bg color change). I can do this in PHP using conditional logic to set an active class by setting a variable on each page which identifies the current page.
For example something like if($page == 2){ echo "active" }
But, I want to achieve this using CSS. I have googled this and found ways of adding active class on "each" page which is very simple but the problem is I have my navigation menu on a single header file where that method requires to have menu on all the pages separately.
How can I achieve this using CSS, or Javascript / jQuery if it is not possible using CSS?