Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Setup & site building · Guide

How to Do Anchor Links in WordPress (Step by Step)

How to Do Anchor Links in WordPress (Step by Step)

Short answer

Select the block you want to jump to, open Advanced in the block settings and type a name in the HTML anchor field, such as pricing. Then link to it with #pricing on the same page, or add #pricing to the end of the page URL from anywhere else.

Key takeaways

  • Anchor links need a target ID and a link with a matching hash.
  • Use the HTML anchor field under Advanced in the block editor.
  • Use the full URL plus the anchor in menus.
  • Elementor uses the Menu Anchor widget or a CSS ID.
  • scroll-behavior and scroll-margin-top fix scrolling and sticky headers.

To make an anchor link in WordPress, give the target block an HTML anchor in its Advanced settings, then link to it with a hash, such as #pricing, from text, a button or a menu.

An anchor link, also called a jump link or page jump, takes the reader to a specific spot on a page instead of the top. They are useful for:

  • Tables of contents on long posts.
  • Back to top links.
  • One-page sites where the menu scrolls to each section.
  • Linking straight to an answer on an FAQ or pricing page.

Every anchor link has two parts:

  1. The target, which is an element with an ID, such as a heading with id="pricing".
  2. The link, which points to that ID with a hash, such as #pricing.

The steps below cover the block editor, the classic editor, menus, page builders and a few extras like smooth scrolling. WordPress.org's own article on page jumps describes the same core method.

How do you add an HTML anchor to a block?

Select the block you want to jump to, open the block settings sidebar, expand Advanced, and type a short name in the HTML anchor field.

Step by step in the block editor:

  1. Click the heading or other block that should be the target.
  2. Open the Settings sidebar using the gear icon at the top right.
  3. Make sure the Block tab is selected.
  4. Scroll down and open Advanced.
  5. In HTML anchor, type a name such as pricing.
  6. Update or publish the post.

Headings are the most common target, but many core blocks support HTML anchors, including groups, columns, images and paragraphs. If you do not see the field, that block does not support it. Block developers turn this on with the anchor block support. Wrap the content in a Group block and add the anchor to the group instead.

Rules for anchor names:

  • Use lowercase letters, numbers and hyphens, such as faq-shipping.
  • Do not use spaces.
  • Make each anchor unique on the page.
  • Do not include the # symbol in the anchor field itself.

Select the text or button, click the link icon, and type the anchor name with a hash in front, such as #pricing, then press Enter.

For a link on the same page:

  1. Highlight the words you want to turn into a link.
  2. Press Ctrl+K or Cmd+K, or click the link icon in the toolbar.
  3. Type #pricing and press Enter.

For a link from a different page, add the anchor to the end of the full URL:

https://example.com/plans/#pricing

You can use the same format in Button blocks, image links and anywhere else WordPress accepts a URL.

For general help with links, see our guide on how to add a hyperlink in WordPress.

In the classic editor, switch to the Text tab, add an id attribute to the target element, then create a normal link that points to #your-id.

The classic editor has no anchor field, so you add the ID in HTML.

  1. Click the Text tab above the editor.
  2. Find the heading you want to target.
  3. Add an ID inside the opening tag:
<h2 id="pricing">Pricing</h2>
  1. Elsewhere, add the link:
<a href="#pricing">See pricing</a>
  1. Switch back to Visual and update the post.

Older guides sometimes use <a name="pricing"></a> as the target. That still works in browsers but is outdated. Using an id on the element itself is the modern approach, as explained in MDN's reference for the id attribute.

Add a Custom Link to the menu with a URL such as #pricing for one-page sites, or the full page URL plus the anchor if the menu appears on other pages.

In a classic theme:

  1. Go to Appearance > Menus.
  2. Open Custom Links.
  3. Enter the URL, for example https://example.com/#pricing, and the link text Pricing.
  4. Click Add to Menu, then Save Menu.

Using the full URL is safer than just #pricing. A bare hash only works on the page that has the anchor. On every other page, the menu link would go nowhere.

In a block theme, edit the Navigation block in Appearance > Editor, add a custom link and paste the same URL.

Our guide on linking a page to a menu explains menu items in more detail.

In Elementor, add a Menu Anchor widget above the target section and give it an ID, or set the CSS ID of a section or container under its Advanced tab.

Two common methods:

  • Menu Anchor widget: drag the widget just above the section, type an anchor ID such as pricing, then link to #pricing.
  • CSS ID: select a section, container or widget, go to Advanced, and type the ID in the CSS ID field.

Elementor's Menu Anchor widget documentation has screenshots. If your links do not scroll to the right spot, our guide to fixing the Elementor menu anchor covers the common causes.

Other builders, such as Divi and Beaver Builder, have similar CSS ID fields in their advanced settings.

Add one line of CSS, html { scroll-behavior: smooth; }, so the browser animates the jump instead of snapping straight to the section.

By default, anchor links jump instantly. Smooth scrolling feels nicer on long pages.

Add this CSS in Appearance > Customize > Additional CSS, or in the Styles panel of a block theme:

html {
  scroll-behavior: smooth;
}

MDN explains the property and browser support on its scroll-behavior page.

Some themes already include smooth scrolling as an option. If both are active, you may get odd results, so use one or the other.

Why does the sticky header cover the heading?

A sticky or fixed header can hide the top of the section you jump to; add scroll-margin-top to anchored elements so the browser stops a little higher.

This is one of the most common anchor link problems. The page scrolls correctly, but the header sits on top of the heading.

Fix it with CSS:

[id] {
  scroll-margin-top: 100px;
}

Set the value to roughly the height of your header. You can target only headings with h2[id], h3[id] if you prefer.

If clicking the link does nothing or lands in the wrong place, the anchor name probably does not match exactly, appears twice, or is being changed by a plugin or script.

Check these:

ProblemFix
Link does nothingMake sure the link has # and the anchor field does not
Wrong spotCheck for duplicate IDs on the page
Works on one page onlyUse the full URL plus the anchor in menus
Jumps then shiftsLazy-loaded images move content; set image sizes
Header covers headingAdd scroll-margin-top
Case mismatchIDs are case-sensitive, so keep them lowercase

Also test in a private window with caching cleared. Some optimisation plugins delay scripts and can affect theme smooth scrolling. For other link problems, see our guide on why a WordPress link is not working.

Yes, table of contents blocks and plugins can add IDs to every heading and build the links for you, which saves time on long articles.

Many table of contents plugins scan your headings, add IDs and create a linked list at the top of the post. Some SEO plugins include a table of contents block as well.

This is the best option if you write long guides often. Our guide on adding a table of contents in WordPress compares the main approaches.

Clear, descriptive headings also help readers and search engines. See our article on when and why to use headings in WordPress for tips.

Frequently asked questions

Where is the HTML anchor field in WordPress?

Select a block, open the Settings sidebar with the gear icon, choose the Block tab and expand Advanced. The HTML anchor field is there. If a block does not show it, that block does not support anchors, so wrap it in a Group block.

Should I include the hash in the HTML anchor field?

No. Type only the name, such as pricing, in the anchor field. Add the hash only in the link itself, such as #pricing on the same page or the full page URL followed by #pricing from elsewhere.

How do I link to an anchor on another page?

Add the anchor to the end of the page URL, for example the page address followed by #pricing. When a visitor clicks it, the browser loads the page and then scrolls to the element with that ID.

Why does my anchor link land too low on the page?

A sticky header is probably covering the top of the section. Add scroll-margin-top to elements with IDs in your CSS, set to roughly your header height, so the browser stops slightly above the target.

Do anchor links help SEO?

They can help readers find answers quickly, and search engines sometimes show jump links to sections in results. They are not a ranking trick, but a clear table of contents with descriptive headings improves usability on long pages.

Sources

  1. Page jumps WordPress.org
  2. id attribute MDN Web Docs
  3. scroll-behavior MDN Web Docs
  4. Menu Anchor widget Elementor

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.