If an anchor link jumps to the right section but the heading disappears behind your sticky header, give the page a scroll offset. For a header that affects the whole page, set scroll-padding-top on the document. For a handful of targets that need extra clearance, set scroll-margin-top on those targets instead. Both approaches leave the normal spacing of the article intact.
This guide shows how to measure the obstruction, choose the right rule and test links that arrive from another page. It also explains why a fix can work in the WordPress editor but fail on the public site, or work on desktop but fail when the navigation changes height on a phone.
1. Confirm the link reaches the right target
Click the affected link and check the address bar. A fragment is the part after the hash sign. For a link ending in #delivery, look at the destination page and make sure one element has the ID delivery. In the block editor, a Heading block may expose an HTML anchor field under Advanced. Use the ID without the hash in the field and include the hash in the link destination.
Scroll up a little after the jump. If the heading appears just under the fixed navigation, the browser probably found the target and placed it under something that stays on screen. If it landed on another section, check for duplicate IDs. If it did not move at all, verify that the target exists on the same page or that the link points to the right page before changing any CSS.
Test an existing section near the middle of the article first. At the bottom of a short page, the browser may run out of space to scroll before it can place a heading just below the header. That is a useful test case later, but it can confuse the initial diagnosis. Use enough content below your first test target to distinguish a scroll offset issue from the end of the document.
2. Measure how much of the viewport is covered
Open the public page in a window where you are signed out. Scroll far enough to activate the sticky header, then inspect it in Chrome DevTools. Hover over the header element in the Elements panel and check its highlighted bounds. If several bars remain pinned at the top, measure their combined visible obstruction. A site could have a small promotional row and a separate navigation bar, for instance.
A useful first value is the vertical distance from the top of the viewport to the bottom of the obstruction, plus a small reading gap. If a sticky header is 64 pixels tall and starts at the top edge, 76 pixels leaves 12 pixels of space before the heading. If the navigation begins below another pinned bar, include that bar in the measurement. Use the size that applies while the page is scrolled, since some headers shrink after the reader moves down.
Repeat on a narrow mobile viewport. The phone version may have a shorter single-row header or a taller navigation with wrapped text. Use the actual breakpoint in your stylesheet rather than assuming every site switches at a particular width. If the header changes when readers increase their text size, test a zoomed view as well. A narrow view at normal zoom does not cover every way the header can grow.
3. Give the page a site-wide offset
For ordinary pages where the document scrolls, put the rule on the root element. The following example leaves 76 pixels on larger screens and 100 pixels on narrower screens. Replace those numbers and the breakpoint with the values you measured. Add the rule through your theme's supported CSS settings or a maintained stylesheet. Try it in DevTools first if you want to see the result before saving it.
html {
scroll-padding-top: 76px;
}
@media (max-width: 700px) {
html {
scroll-padding-top: 100px;
}
}
Click the same link again. The browser should position the target lower in the visible area, with its heading clear of the pinned navigation. The property adjusts the preferred viewing region for scrolling. It does not add 76 pixels of ordinary layout padding above every section. The distinction matters because the article should still look the same when readers scroll through it manually. The MDN scroll-padding-top reference explains what the offset applies to.
If your theme already defines scroll padding, use the existing rule if you can. Check the computed value after your change. A theme stylesheet loaded later can override an earlier declaration, and a different mobile rule may override the desktop value. Keep one clear place to update the offset when the header design changes. If the theme already uses a variable for the sticky header height, use the same value when it accurately reflects the scrolled state.
4. Use scroll margin for selected headings
If only a few sections need clearance, put the offset on the actual target. For a page with a table of contents, you might give the headings in that article a shared class and apply scroll-margin-top to that class. In WordPress, a block can usually receive an additional CSS class through its Advanced settings. Enter the class name without a leading dot in that field. Add the dot when writing the CSS selector.
.section-anchor {
scroll-margin-top: 76px;
}
Add the class to the element that has the target ID. If the ID belongs to a Group block around the heading, a rule on the heading inside that group may not affect the jump. Inspect the front-end markup if you are unsure. The relevant element is the one the browser lands on when it follows the fragment. The MDN scroll-margin-top reference describes the target-side offset.
Start with one offset method. Applying the full header height to both the root and every target can leave a much bigger gap than you expected. If you need a page-wide amount plus a small extra gap for a particular component, use those values deliberately and test the combined result. Examine both computed properties if the heading lands further down than either of your individual measurements would suggest.
5. Check which element is doing the scrolling
Some sites keep the browser viewport fixed and let a panel scroll inside it. A sidebar, modal or app-style article pane may have a constrained height and its own vertical scrollbar. In that case, a rule on the document may do nothing for the panel. Select the panel in DevTools, inspect its overflow and scroll it with the mouse. If the panel moves while the page around it stays in place, test the scroll padding on that panel.
Measure the obstruction inside that panel rather than automatically borrowing the height of the main navigation. The panel could have a separate pinned toolbar. Position the target so it remains visible when you follow a link inside that panel, then test a link elsewhere on the site. Applying the fix to the intended scroll container keeps a local component from changing anchor behaviour across unrelated pages.
If the link is controlled by a theme script, check whether it uses a native fragment or calculates its own scroll position. Scripted navigation can use a fixed pixel value that ignores the offset you expect from CSS. Look for a theme setting for anchor offset or smooth scrolling and try its documented method. Save the original and retest. Turning off arbitrary scripts makes it harder to see which part actually caused the jump.
6. Test direct visits, keyboard navigation and the mobile header
Open the full public URL with the fragment in a new tab. This checks the path readers use when they arrive from a link in another article or an email. Then click the same link from the table of contents. Both should reveal the heading. Refresh at the same address and repeat after the page's fonts and images finish loading. Content that changes size above the destination can move the heading after an initially correct jump.
Next test with the keyboard. Use Tab to reach the link, activate it and check that the next relevant controls remain visible when they receive focus. Test close to the top and bottom of the viewport. A sticky header can hide a focused control even when an ordinary anchor looks fine. The W3C technique for using CSS scroll padding provides an example of keeping scrolled content clear of a pinned surface.
Repeat at the narrow widths where the header changes. Test the menu closed, and try an anchor reached from the open mobile menu if your theme provides one. A menu that stays expanded after selection can cover the destination regardless of the offset. Check the intended close behaviour of the navigation before making the offset large enough to accommodate a panel that is supposed to disappear.
Finally, compare an editor view with a public signed-out view. The WordPress admin bar may add an obstruction for signed-in users that ordinary readers never see. Make the public header the baseline and, if you need to fix the signed-in editing experience too, use a rule scoped to the admin-bar state. If the page also scrolls sideways on mobile, the flex layout overflow guide covers that separate test.
When the heading is still partly hidden
Check the computed offset, the element that owns the ID and the height of the header after the jump. Then try a middle section that has plenty of room underneath. If that works but the last section does not land in the same place, inspect how much content follows it. The browser can only scroll as far as the document allows. Add end space only if that makes sense for the page, or accept that the final section will land wherever it remains fully visible.
If the offset works in DevTools but seems absent after deployment, check that the public response contains the new stylesheet. A cache or a CSS build step may still serve an earlier version. Verify the computed property before adding another override. Then save one test URL for desktop and one for mobile so you can repeat the check the next time you change the header. For more practical walkthroughs, see the Guides archive.
Keep the offset easy to update
Record the tested height and where you set the offset. If the site has a shared theme stylesheet, leave a short note beside the declaration identifying the pinned bars it accounts for. When someone adds a banner above the menu, they can check the combined height without searching every post for an individual rule. If a page has its own navigation or scroll panel, document that exception with the component instead.
Include the link to a middle heading and the smallest viewport that showed the problem. A reviewer can then test the old failure case, a direct visit and a keyboard focus move in one pass. Repeat that check when the navigation or article template changes.
