
Have you ever clicked a link and been taken directly to the exact paragraph you needed, rather than the top of a long page? That experience is powered by anchor links, sometimes called jump links. Learning how to link to a part of a web page helps you create better documentation, FAQs, long-form articles, and single-page websites. This guide explains how anchor links work and how to create them across different platforms.
AAMAX.CO: Single-Page and Long-Form Website Specialists
Single-page websites and long-form content depend on smooth, intuitive in-page navigation. AAMAX.CO is a full-service digital marketing company offering web development, digital marketing, and SEO services worldwide. Their team designs engaging single-page experiences, sticky navigation bars, and anchor-based menus that keep visitors oriented. Businesses that want polished landing pages and content-rich layouts can rely on their website design services for seamless user experiences.
What Are Anchor Links?
Anchor links are hyperlinks that point to a specific location within a page rather than the page as a whole. They work by combining an id attribute on the target element with a URL fragment that begins with a hash symbol. When the browser loads a URL containing a fragment, it automatically scrolls to the matching element.
Creating Anchor Links in HTML
First, add an id to the part of the page you want to link to:
<section id="faq">
<h2>Frequently Asked Questions</h2>
</section>Then create a link that points to it:
<a href="#faq">Jump to FAQs</a>To link to that part from another page, add the page path before the fragment, such as help.html#faq.
Legacy Name Anchors
Older websites sometimes used the name attribute on anchor elements to create targets, for example an empty anchor with a name value. This approach is obsolete in modern HTML. Use the id attribute on any element instead, which is cleaner and widely supported.
Creating Anchor Links in WordPress
In the WordPress block editor, select the heading or block you want to target, open the Advanced panel in the block settings sidebar, and enter a value in the HTML anchor field. Then highlight the link text elsewhere, click the link icon, and type the hash symbol followed by your anchor name. Many table-of-contents plugins can generate anchors automatically for every heading.
Creating Anchor Links in Website Builders
Most website builders support anchor links. In Wix, you add an anchor element to the page and link buttons or text to it. Squarespace allows you to add ids through code or use section anchors. Webflow lets you assign an id to any element in the settings panel and link to it from navigation or buttons. Check your builder's documentation for exact steps.
Adding a Back-to-Top Link
On long pages, a back-to-top link improves navigation. Give your top element an id or use the special fragment #top, which most browsers treat as the top of the page:
<a href="#top">Back to top</a>Place this link at the end of long sections or as a floating button that appears after scrolling.
Building a Table of Contents
A table of contents at the beginning of a long article allows readers to jump directly to the sections that interest them. Create a list of links pointing to the ids of each heading. This improves usability and helps search engines understand your content structure, sometimes resulting in section links appearing directly in search results.
Smooth Scrolling
Instead of jumping instantly, you can animate the scroll with CSS:
@media (prefers-reduced-motion: no-preference) {
html { scroll-behavior: smooth; }
}Wrapping the rule in a reduced-motion media query respects users who are sensitive to animation.
Fixing Sticky Header Overlap
When a site uses a sticky header, targets can end up hidden beneath it. Use scroll-margin-top on the target elements to offset the scroll position:
[id] { scroll-margin-top: 6rem; }Adjust the value to match your header height.
Highlighting the Target Section
The CSS :target pseudo-class lets you style the element currently referenced by the URL fragment. You might add a subtle background highlight so users immediately see where they landed. This visual cue is especially helpful on dense pages.
Best Practices
Use short, descriptive, lowercase ids with hyphens. Ensure every id is unique on the page. Avoid changing ids after publishing, since external links may depend on them. Test anchor links on desktop and mobile devices to confirm they scroll to the right position.
Troubleshooting Anchor Links
If an anchor link does not work, check that the id exists and matches the link exactly, including capitalization. Confirm there are no duplicate ids on the page. If the page loads content dynamically, the target may not exist yet when the browser tries to scroll.
Conclusion
Linking to a part of a web page is easy with anchor links. Add an id to the target element, link to it using a hash fragment, and use the same approach across pages, WordPress, and website builders. Enhance the experience with tables of contents, back-to-top links, smooth scrolling, scroll offsets, and target highlighting. These techniques make long pages far more navigable and enjoyable for your visitors.