URL fragment identifiers

The Citead team, updated

In short. A URL fragment identifies a secondary resource and is handled by the user agent after being separated from the retrieval URL.

Definition: A URL fragment identifier is the component introduced by # that identifies a secondary resource, such as a section within a document. RFC 3986 specifies that the user agent separates the fragment from the URL before retrieving the primary resource and interprets it locally.

Key facts

  • RFC 3986, section 3.5 makes fragment interpretation depend on the retrieved representation's media type, the format label associated with that representation.
  • The WHATWG HTML Standard's id rules allow an element's identifier to serve as the target of a fragment link.
  • As of 17 October 2026, Google's URL structure guidance advises against changing page content through fragments because Google Search generally does not support them for that purpose.

What happens during retrieval?

RFC 3986 separates identifying a secondary resource from retrieving its containing resource. The user agent, the client handling the URL, removes the fragment before performing the retrieval. It then handles the fragment according to the representation's media type. HTML section targeting is one application of this general mechanism.

Section 4.4 calls a reference a same-document reference when its resolved URL matches the base URL apart from the fragment. Following such a reference should avoid a new retrieval. Section 6.1 also directs applications to exclude fragments when comparing URLs to decide whether to perform a network retrieval. Consequently, different fragment targets can share the same retrieved document.

The HTML Standard defines id as an element's unique identifier. Its value must contain at least one character, contain no ASCII whitespace, and be unique among IDs in the element's tree. This illustrative markup follows those rules:

<a href="#details">Read the details</a>
<h2 id="details">Details</h2>

The HTML fragment selection algorithm looks for an element whose ID equals the fragment. In this example, #details identifies the heading. The algorithm also supports the name attribute on an a element as a fallback. The standard treats IDs as opaque strings, so the word details has no special built-in meaning.

What changes for a website's search access?

Google's URL structure documentation gives this example of a fragment used to change content:

https://example.com/#/potatoes

The documentation recommends the History API, a browser interface for managing session history, when JavaScript changes content. For a site with separate content views, this makes URL design relevant to search access: Google explicitly cautions against relying on fragment changes for those views.

An HTML section link serves a different purpose: it points into a document through an element identifier. The Google guidance concerns changing page content through fragments; the HTML rules define how an existing section becomes a link target.

FAQ

Does the fragment reach the server in the retrieval URL?

RFC 3986 requires the user agent to separate it before retrieval. The fragment target is handled on the client side.

Does a question mark after the hash start a query?

No. The same RFC permits ? and / as data inside a fragment. Its query rules place the query component before the # separator.

What happens if the target ID is missing?

The HTML selection algorithm also checks named anchors and tries a percent-decoded fragment. If no target matches, it returns no indicated part, with a special rule for top that selects the document's beginning.

Sources

  1. IETF, "Uniform Resource Identifier (URI): Generic Syntax", January 2005
  2. WHATWG, "HTML Standard: Elements in the DOM", updated 16 October 2026
  3. WHATWG, "HTML Standard: Navigation and session history", updated 16 October 2026
  4. Google Search Central, "URL structure best practices for Google Search", updated 10 December 2025
  5. WHATWG, "HTML Standard: APIs related to navigation and session history", updated 16 October 2026

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark