One role of providing a class for li navigation is to display which one is active for page navigation. It can be a different color or a different background to demonstrate that the link is an active page.
This can be done easily in php, in which the active page is called before the / nav header is called.
for example - setting the active page variable:
<?php $activePage="home";?>
// other code associated with the navigation menu // include a common header / navigation file
<li class="<?php if($activePage =="home"){echo"active";}?>"><a href="index.php">HOME</a></li>
What this does allows a general level menu that indicates the active page you are on, and therefore can be styled accordingly. And each page in the navigation menu can have an active class if it is an active page. Therefore, there is one navigation menu that runs differently on different pages in accordance with the setting of the activePage class.
By the way, the $ activePage variable can also be used in the footer, if you have navigation elements in the footer - and therefore allows you to style the link of the active page at the top and bottom of the page.
source share