URI fragment explained

In computer hypertext, a URI fragment is a string of characters that refers to a resource that is subordinate to another, primary resource. The primary resource is identified by a Uniform Resource Identifier (URI), and the fragment identifier points to the subordinate resource.

The fragment identifier introduced by a hash mark # is the optional last part of a URL for a document. It is typically used to identify a portion of that document. The generic syntax is specified in RFC 3986.[1] The hash mark separator in URIs is not part of the fragment identifier.

Basics

In URIs, a hash mark # introduces the optional fragment near the end of the URL. The generic RFC 3986 syntax for URIs also allows an optional query part introduced by a question mark ?. In URIs with a query and a fragment, the fragment follows the query. Query parts depend on the URI scheme and are evaluated by the server—e.g., http: supports queries unlike ftp:. Fragments depend on the document MIME type and are evaluated by the client (web browser). Clients are not supposed to send URI fragments to servers when they retrieve a document.[2]

A URI ending with # is permitted by the generic syntax and is a kind of empty fragment. In MIME document types such as text/html or any XML type, empty identifiers to match this syntactically legal construct are not permitted. Web browsers typically display the top of the document for an empty fragment.

The fragment identifier functions differently to the rest of the URI: its processing is exclusively client-sided with no participation from the web server, though the server typically helps to determine the MIME type, and the MIME type determines the processing of fragments. When an agent (such as a web browser) requests a web resource from a web server, the agent sends the URI to the server, but does not send the fragment. Instead, the agent waits for the server to send the resource, and then the agent processes the resource according to the document type and fragment value.[3]

In an HTML web page, the agent will look for an anchor identified with an HTML tag that includes an id= or name= attribute equal to the fragment identifier.

Examples

Proposals

Several proposals have been made for fragment identifiers for use with plain text documents (which cannot store anchor metadata), or to refer to locations within HTML documents in which the author has not used anchor tags:

<nowiki>https://pypi.python.org ... zodbbrowser-0.3.1.tar.gz#md5=38dc89f294b24691d3f0d893ed3c119c</nowiki>

<nowiki>http://example.com/page?query#!state</nowiki>

<nowiki>http://example.com/index.html#!s3!search terms</nowiki>

<nowiki>http://example.com/document.txt#match=[rR][fF][cC]</nowiki>

<nowiki>http://example.com/index.html#:words:some-context-for-a-(search-term)</nowiki>

<nowiki>http://example.com/index.html#115Fragm8+-52f89c4c</nowiki>

See also

External links

Notes and References

  1. News: RFC 3986 Uniform Resource Identifier (URI): Generic Syntax . Internet Engineering Task Force . January 2005 . 2012-03-06.
  2. Web site: Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing. Internet Engineering Task Force (IETF). R. Fielding, Ed., Adobe. J. Reschke, Ed., greenbytes. June 2014. 2023-12-27. The target URI excludes the reference's fragment component, if any, since fragment identifiers are reserved for client-side processing.
  3. Web site: Representation types and fragment identifier semantics . . 2004 . Architecture of the World Wide Web, Volume One . 2011-07-13.
  4. Web site: Obsolete features . HTML Living Standard . 2024-08-07 . . 2024-08-08.
  5. Web site: Validity constraint: ID . XML 1.0 (Fifth Edition) . 2008 . . 2011-07-13.
  6. Web site: xml:id Version 1.0 . . 2005 . 2011-07-13.
  7. Web site: Issue 77024 . Chromium . 2011 . 2011-07-13.
  8. Web site: Media Type Review . W3C Media Fragments Working Group . 2009 . 2009-04-29.
  9. Web site: New Feature: Link within a Video . 2006-07-19 . 2011-07-13.
  10. Web site: Link To The Best Parts In Your Videos . . 2008-10-30 . 2011-07-13.
  11. http://blogoscoped.com/archive/2007-11-17-n25.html Link to Specific Content in Gmail
  12. News: Bryan . P . RFC 6901 – JavaScript Object Notation (JSON) Pointer . 2 April 2013 . The Internet Society . 14 July 2022.
  13. Web site: Parameters for Opening PDF Files – Specifying parameters in a URL . Adobe . April 2007 . 2017-09-20.
  14. RFC 3778 – The application/pdf Media Type . tools.ietf.org . The Internet Society . May 2004 . 10.17487/RFC3778 . 2017-09-20. Taft . E. . Pravetz . J. . Zilles . S. . Masinter . L. .
  15. Web site: Linking – SVG 1.1 (Second Edition).
  16. Web site: Media Fragments URI 1.0 (basic) W3C Recommendation . 2012-09-25.
  17. Web site: Scroll to Text Fragment . Chrome Platform Status . . 2020-05-18. en.
  18. Web site: Kelly. Gordon. Google Chrome 80 Released With Controversial Deep Linking Upgrade. 2020-06-04. Forbes. en.
  19. Web site: WICG/scroll-to-text-fragment: Proposal to allow specifying a text snippet in a URL fragment . GitHub . . 2020-05-18. en.
  20. Web site: Pypi md5 check support . Pypi has the habit to append an md5 fragment to its egg urls, we'll use it to check the already present distribution files in the cache . 2011-07-13.
  21. Web site: Hash URIs . 2011-05-12 . W3C Blog . 2011-07-13.
  22. Web site: HTML 5.1 2nd Edition . 2017 . . 2018-08-03.
  23. Web site: Proposal for making AJAX crawlable . 2009-10-07 . 2011-07-13.
  24. Web site: (Specifications) Making AJAX Applications Crawlable . Google Inc. . 2013-05-04.
  25. Web site: Manipulating the browser history . Mozilla Developer Network . en-US . 2017-02-23.
  26. News: Deprecating our AJAX crawling scheme . Official Google Webmaster Central Blog . 2017-02-23 . en-US.
  27. http://www.gerv.net/software/fragment-search/ Fragment Search
  28. Fragment identifiers for plain text files, Erik Wilde and Marcel Baschnagel, Swiss Federal Institute of Technology (ETH Zürich), Proceedings of the sixteenth ACM conference on Hypertext and hypermedia
  29. http://zesty.ca/crit/draft-yee-url-textsearch-00.txt Text-Search Fragment Identifiers
  30. Web site: bmcquade . bokan . nburris . Feature: Scroll to Text Fragment . Chrome Platform Status . chromium.org . 3 May 2022 . 2022-03-24.
  31. http://liveurls.mozdev.org/index.html LiveURLs project
  32. http://liveurls.mozdev.org/tech.html The technology behind LiveURLs
  33. https://addons.mozilla.org/en-us/firefox/addon/web-marker/ "Web Marker" Firefox add-on
  34. Web site: EPUB Canonical Fragment Identifiers 1.1. 2020-06-03. idpf.org.