A fragment identifier is the last part of a URL, starting with the # character. It points to a specific part of a resource, such as a section of a page or a position in a video.
How does a fragment work?
The browser processes the fragment after it has loaded the resource. The fragment is never sent to the server (MDN). Common uses are:
- Scroll to an element.
#syntaxscrolls to the element withid="syntax". - Text fragments.
#:~:text=wordhighlights a piece of text. - Media fragments.
#t=10,20plays audio or video from second 10 to 20.
RFC 3986 defines the fragment as an indirect reference to a secondary resource, with semantics set by the media type of the retrieved content. When URIs are compared, fragments are left out, since they reference content within one resource.
What does Google say about fragments?
Google states that its Search generally does not support URL fragments. It advises against using fragments to change the content of a page and against using fragment identifiers for page numbers in a collection, because Google ignores them. For JavaScript apps, Google points to the History API as the way to give each view its own URL.
For filters on large catalogs, Google’s faceted navigation page lists fragments as one option for keeping filter URLs out of the crawl, since the fragment does not create a new URL for crawling.
Example
https://example.com/guide?lang=en#faq
Here ?lang=en is the query string. #faq scrolls to the element with the ID faq.
Sources
- URI fragment – MDN Web Docsdeveloper.mozilla.org
- RFC 3986, section 3.5 Fragment – IETFrfc-editor.org
- URL structure best practices for Google Search – Google Search Centraldevelopers.google.com
- Pagination and incremental page loading – Google Search Centraldevelopers.google.com
Last updated: