Free GA4 auditCheck

Anchor

Definition

In HTML, an anchor is the <a> element that creates a link, and also a marked point on a page that such a link can lead to. In SEO and web development practice, an “anchor” most often means a link to a specific section of a page. Such an address ends with a # sign and the section identifier, e.g. https://zest.agency/#manifest. After a click, the browser scrolls the page straight to that spot.

An anchor should not be confused with anchor text. Anchor text is the visible, clickable content of a link, e.g. “Poznaj nas” (“Get to know us”). An anchor in the sense of a URL anchor is the destination within a page, and the <a> element is the link itself, which connects the two.

How does a URL anchor work?

A URL anchor works by combining two elements: an id attribute on a page section and a link ending with # followed by the same name. The part of the address after # is called the fragment. The browser does not send it to the server; after loading the page, it looks for an element with a matching identifier and scrolls the view to it. MDN describes this as linking to a section of a page using document fragments.

Example on zest.agency

On the zest.agency home page, the “Poznaj nas” (“Get to know us”) button leads to https://zest.agency/#manifest. The section with the agency's manifesto has the attribute id="manifest" in its code. After a click, the page scrolls to that section instead of opening a new address.

ElementCode on zest.agency
Link (<a> element)<a href=https://zest.agency/#manifest>Poznaj nas</a>
Destination<section id="manifest">…</section>
Anchor textPoznaj nas
Fragment in the address#manifest

On the same page, the faq and contact sections also have identifiers. The addresses https://zest.agency/#faq and https://zest.agency/#contact therefore lead straight to the questions section and the contact section. Links like these often go into the navigation menu of one-page websites.

Special anchors

According to MDN, a link with href="#top" or an empty fragment href="#" leads to the top of the current page. “Back to top” buttons rely on this rule. They do not require adding a separate identifier in the code.

How does a URL anchor work?

Why do anchors matter for SEO?

Anchors matter for SEO on two levels: as links that a crawler can follow, and as anchors to sections that Google can show in search results. Google says it can reliably crawl links only when they are <a> elements with an href attribute. Elements that imitate links, e.g. a <span> with a JavaScript click handler, may be ignored.

Does Google index URLs with a # fragment?

Not as separate pages. In its URL structure guidelines, Google notes that it generally does not support URLs with fragments. That is why it does not recommend using fragments to change page content. When JavaScript swaps content, Google recommends the History API instead of #. All addresses such as https://zest.agency/#faq are therefore treated as one page, https://zest.agency/.

Google may show a link in the result snippet that leads directly to a section of the page, a so-called read more deep link. In April 2026 Google added three recommendations on such links to its documentation:

  • content should be visible immediately on load, not hidden in tabs or expandable sections;
  • scripts should not force the scroll position when the page loads;
  • the page should not remove the # fragment from the address after loading.

Dividing text into clearly marked sections with identifiers also makes content chunking easier. Each section becomes a self-contained fragment that users can be sent to.

How should anchors be used on a page?

Anchors work well when identifiers are unique, readable and stable over time. Changing a section identifier breaks every link that pointed to it, including links from other pages.

RuleExample
Each identifier only once per pageOne section with id="faq", not two
Descriptive name instead of a random one#manifest instead of #section-3
Lowercase letters and hyphens instead of spaces#cennik-uslug
Descriptive anchor text on the link“Get to know us” instead of “Click here”
Offset for a sticky menuThe #manifest section on zest.agency has the class scroll-mt-20

The last rule applies to pages with a menu stuck to the top edge of the screen. Without an offset, the section heading disappears under the menu after scrolling. On zest.agency this is solved by the scroll-mt-20 class, which adds a top scroll margin. In plain CSS the same effect comes from the scroll-margin-top property.

Google recommends that anchor text be descriptive, concise and related to the content of the destination page. It advises against generic phrases such as “click here” and against stuffing keywords into links. The same rule applies to links to sections, e.g. in an article's table of contents.

Frequently asked questions

Q.What is the difference between an anchor and anchor text?

An anchor is a link (the <a> element) or a destination within a page marked with an identifier. Anchor text is the visible, clickable content of the link. In the address https://zest.agency/#manifest, the anchor is the #manifest fragment, and the anchor text on the zest.agency home page is “Poznaj nas” (“Get to know us”).

Q.How do you link to a specific section of a page?

First, give the section a unique identifier, e.g. <section id="manifest">. Then create a link whose address ends with # and the same name, e.g. <a href="#manifest">. From another page, link to it with the full address, e.g. https://zest.agency/#manifest.

Q.Does Google index each # anchor separately?

No, Google says it generally does not support URLs with fragments as separate pages. Addresses with different anchors lead to the same page. Google may, however, show a “Read more” link in results that leads to a specific section, provided the content is visible when the page loads.

Q.Why doesn't a link with an anchor scroll the page to the section?

The most common cause is that no element has an identifier matching the fragment in the address, or that letter case differs. Scrolling can also be blocked by scripts that force the page position on load. If the section hides under the menu, the CSS scroll-margin-top property helps.

Contact

Let's talk growth

Send a brief or drop your contact. We'll reply within 24h.

Get a quote
Paweł Strzelecki and Karol Majewski, co-founders of Zest