DevOps

Handling UX when scrolling to anchors at the bottom of a page

Where to scroll when navigating to anchor at bottom of page?

Asked on Stack Exchange,

When an anchor link near the bottom of a page cannot scroll to the top of the viewport, the recommended UX approach is to visually highlight the targeted section using CSS or to add sufficient bottom spacing such as a large footer.

Highlighting the targeted section

The top-rated answer recommended using the CSS :target pseudo-class to visually distinguish the target element whenever a fragment link is activated. By placing an id attribute directly on the heading tag, developers can apply a background colour change or flash to draw the user's eye immediately to the relevant heading.

  • Applying a background colour highlight via the CSS :target selector.
  • Using subtle movement or animation to draw attention to the target header.
  • Expanding the page footer to provide enough vertical scroll space at the bottom.

Persistent cues across navigation methods

One reply pointed out that using the :target selector works reliably regardless of how the page was accessed, including bookmarked links or background tabs. The visual highlight persists even if layout shifts occur, similar to native browser features that highlight text targets.

Increasing scroll space with large footers

Another contributor noted that several major platforms mitigate this issue by adding tall footers to their layout. Creating extra vertical space at the end of a document allows short bottom sections to scroll further up the screen towards the top of the viewport.