Styling Active Router Link in Angular Last Updated : 17 Jun, 2021 Comments Improve Suggest changes Like Article Like Report Styling the active router link in angular allows the user to differentiate between the active router link and inactive router links. Angular provides a special mechanism to work with active router links. Approach: Create the Angular app to be used.Create the header component that contains the navigation links.Then apply the "routerLinkActive" on each router link and provide the CSS class to this property. Here we have created the "active" class in CSS file.Provide the { exact : true } to the root route to avoid multiple active router links. Syntax: <a routerLink="/" routerLinkActive="active" >Home</a> Example: We have created the header component with specified routes. header.component.html <span> <ul> <li><a routerLink="/" routerLinkActive="active"> Home </a></li> <li><a routerLink="/products" routerLinkActive="active">Products </a></li> <li><a routerLink="/about" routerLinkActive="active">About Us </a></li> <li><a routerLink="/contact" routerLinkActive="active">Contact Us </a></li> </ul> </span> <router-outlet></router-outlet> Here we have provided the "routerLinkActive" which is routing functionality that automatically activate the current route, and we have to provide the CSS class as well. Here in routerLinkActive = "active" active is a CSS class that automatically applied to the activated route. header.component.css .active{ background: 'white' } But here, it still causes an issue our Home route is always active even we navigate to some other route the reason behind this is the way "routerLinkActive" works. The home route works on "localhost:4200/" and other routes are "localhost:4200/about" so "routerLinkActive" finds "localhost:4200/" inside every other route and the Home router link is always active to deal with this angular provide another directive called routerLinkActiveOptions. Updated header.component.htm <span> <ul> <li><a routerLink="/" routerLinkActive="active" [routerLinkActiveOptions]={exact:true}>Home </a></li> <li><a routerLink="/products" routerLinkActive="active">Products </a></li> <li><a routerLink="/about" routerLinkActive="active">About Us </a></li> <li><a routerLink="/contact" routerLinkActive="active">Contact Us </a></li> </ul> </span> <router-outlet></router-outlet> So routerLinkActiveOptions allow only the exact path match as an active route for the Home component. Output: Comment More infoAdvertise with us Next Article Routing in Angular 9/10 D daya1331 Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Questions Similar Reads How to determine active route in AngularJS ? In this article, we will see how to determine the active route in AngularJS, along with understanding the basic implementation through the example. Approach: To determine which is the active route at any moment in AngularJS this can be achieved by using $on() & $location.path() method. An event 2 min read How To Add Styling To An Active Link In NextJS? Styling active links is important for enhancing user navigation by providing visual feedback on the current page or section. In Next.js, you can achieve this by using the Link component from next/link and applying styles conditionally based on the active route. In this article, we will learn about h 3 min read Routing in Angular 9/10 Routing in Angular allows the users to create a single-page application with multiple views and allows navigation between them. Users can switch between these views without losing the application state and properties. Approach: Create an Angular app that to be used.Create the navigation links inside 3 min read RouterOutlet in Angular The Angular RouterOutlet directive serves as a placeholder that Angular fills dynamically based on the current route. RouterOutlet is important in the creation of Single Page Applications (SPAs) since it provides component display mode depending on the URL without the entire page refreshing. Thus, i 6 min read What is Angular Router? Angular Router is an important feature of the Angular framework that helps you to build rich and interactive single-page applications (SPAs) with multiple views. In this article, we'll learn in detail about Angular Router. PrerequisitesNPM or Node jsBasics of AngularBasics of RoutingCode editor ( e. 5 min read Routing in Angular JS using Angular UI Router AngularJS is a front-end web application framework based on JavaScript and is maintained by Google. AngularJS interprets the attributes of HTML as directives to bind input/output components to a model represented by standard JavaScript variables. Pre-requisites: HTML CSS JavaScript AngularJS Angular 3 min read Like