Webflow sync, pageviews & more.
NEW

How can I prevent the "w-current" class in Webflow from overriding the height of my custom class on a link block element?

TL;DR
  • Use a custom class (e.g., nav-link-custom) on link blocks instead of styling the base element to avoid w-current overriding styles.
  • Override w-current behavior by applying layout styles directly in the custom class, using a combo class or custom CSS if needed.

The w-current class in Webflow is a built-in class automatically applied to elements like link blocks when they match the current page or anchor. It often overrides custom styles—especially layout properties—if not handled properly.

1. Understand the Problem with w-current

  • w-current applies styles automatically when a link block points to the currently active page or section.
  • If you've styled a link block with a custom height, w-current may override this if it has conflicting styles set via Webflow Designer.
  • Webflow does not let you style w-current directly — it's contextually applied using the base link class.
  • Webflow often encourages users to style the base Link Block element, which is shared between normal and w-current states.
  • Instead, create and apply a custom class (e.g., nav-link-custom) to the link block, and define height and other layout properties there.
  • Ensure you are not styling All Link Blocks globally unless intentional.

3. Add Specific Height Styling to Your Custom Class

  • Select the link block element.
  • Add or select your custom class (e.g., nav-link-custom).
  • Set your desired height in the Style panel.
  • Make sure you are not relying solely on inherited styles, as w-current may override them.

4. Increase Specificity with a Combo Class (Optional)

  • To override w-current behavior, you can use a combo class that includes both your custom class and the hovered w-current (applied by Webflow).
  • Example: Add a combo class like nav-link-custom w-current in the Style panel (just select an active link and add your custom class).
  • Apply explicit height and layout values to override Webflow’s default behavior for the w-current state.

5. Add Custom Code for Critical Overrides (if needed)

  • If Webflow's Designer won’t let you override w-current, use small custom CSS in the Page Settings > Before tag to target it:

    Example:
    <style>.nav-link-custom.w-current { height: 60px !important; }</style>

  • Be sure to use !important only when necessary, and test across all breakpoints.

Summary

To prevent w-current from overriding your custom link block height, apply a custom class directly to the element, avoid styling the base link block, and optionally use a combo class or custom code to enforce your height styling across all states.

Rate this answer

Other Webflow Questions