Anchor Link Offset to Other Pages with Fixed Header Size

Here is a snippet of code that will link to a anchor link on another page with an offset which allows for a fixed header size, so the link appears just below the header.

The code snippet is documented.


  1. Steve Deardorff on May 15, 2018 at 2:48 pm

    This is the only solution that seems to work for me – none of the CSS options work with WordPress. My only problem with this JS is that I cannot find how to control the amount of the offset. It’s about 100px too much. Any way to set the offset amount through this script? Thanks!

  2. Paul Lacey on April 23, 2018 at 9:31 am

    Neil the WordPress world is a better place for your code snippets.
    This is exactly the kind of thing that’s been bothering me… well since fixed headers, and I never got around to dealing with it in an intelligent way like this.

    Thank you!

    • Neil Gowran on April 23, 2018 at 9:17 pm

      Yes, I seem to be doing more fixed headers lately and was tackling this with html, css hacks, this does it more reliably.

Leave a Comment

%d bloggers like this: