Warning Same-page anchor link with no matching id

Why an href="#section" link needs a matching id on the page, and what happens in the browser when it's missing.

The validator flags an <a href="#fragment"> whose fragment doesn't match the id of any element on the page (or, for older markup, a matching <a name="fragment">).

Example

<!-- Wrong: no element has id="pricing" -->
<a href="#pricing">Jump to pricing</a>

<!-- Right -->
<a href="#pricing">Jump to pricing</a>
...
<section id="pricing">...</section>

Why it matters

A same-page anchor link only works because the browser looks for an element whose id matches the fragment after the # and scrolls it into view. If nothing matches, most browsers silently do nothing useful — some scroll to the very top of the page, which looks like a broken "jump to top" link rather than an error. This is a common casualty of refactors: a heading gets renamed or an id gets removed, and every in-page link pointing at it quietly stops working with no visible error anywhere.

Frequently asked questions

Does this check cross-page links like /page#section?

No — it only checks fragment-only links (href starting with #) against ids on the same page you're validating. A link to another page's anchor can't be verified without fetching that page too.

What about href="#" with no fragment name?

That's a different, separate check (placeholder-href) — an empty fragment is a common intentional pattern for JavaScript-driven controls, not a broken reference.