To style the active link in a Webflow Navbar without relying on the "Current" state class, you can use a custom attribute or page-specific class logic to target the link based on the current URL or a manual identifier.
Webflow automatically adds a unique class to the <body>
tag for each page, which you can use as a CSS selector to style navbar links differently.
<body>
, like page-home, page-about, etc.Example:
If your About page has a body class page-about
, and the navbar link has a class nav-link
, add the following CSS in the head:
<style> body.page-about a.nav-link.about { border-bottom: 2px solid #000; } </style>
Make sure to add a unique class (like about
) to the specific nav link element in Webflow so you can target it properly.
You can manually mark the active page by setting a custom attribute (e.g., data-page="about"
) on each nav link and checking against the current URL.
Assign a custom data-page="about"
to each link pointing to the corresponding page.
Add JavaScript in Site Settings > Custom Code Footer or Page Settings > Footer Code:
``
This dynamically targets the matching nav link based on the current URL.
For small sites, you can manually add a new class to the active nav link on each individual page.
This method is manual but effective for simple sites.
To style the active link without using Webflow’s built-in “Current” state, you can leverage body classes per page, custom attributes with JavaScript, or manual per-page styling. For scalable, dynamic behavior, the JavaScript method is usually best.