Fragment identifier

From Wikipedia, the free encyclopedia

In computer hypertext, a fragment identifier is a short 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. Typically, the fragment identifier is appended to the Uniform Resource Locator (URL —a type of URI) for a hypertext document and is meant to identify a portion of that document.

A fragment identifier is defined by RFC 3986 as an optional component of a URI reference, and it must conform to a certain syntax. The syntax requires that the fragment identifier be separated from the rest of the URI reference by a # (number sign) character. The separator is not considered part of the fragment identifier.

[edit] Examples

  • In HTML applications, http://example.org/schmoo.html#tag1 will refer to the element containing the "anchor" attribute name="tag1" in the document named "http://example.org/schmoo.html". It does not matter if the document is actually accessible at that location on the Internet.
  • In XML applications, http://example.org/schmoo.xml#xpointer(//Rube) should employ an XPointer, returning all XML elements named "Rube" from the document named "http://example.org/schmoo.xml". It does not matter if the document is actually accessible at that location on the Internet.
  • In RDF vocabularies, such as RDFS, OWL, or SKOS, fragment identifiers are used to identify resources in the same XML Namespace, but are not necessarily corresponding to a specific part of a document. For example http://www.w3.org/2004/02/skos/core#broader identifies the concept "broader" in SKOS Core vocabulary, but it does not refer to a specific part of the resource identified by http://www.w3.org/2004/02/skos/core, a complete RDF file in which semantics of this specific concept is declared, along with other concepts in the same vocabulary.

[edit] Processing

The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server. When an agent (such as a Web browser) requests a 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 fragment value. In the most common case, the agent scrolls a Web page down to the anchor element which has an attribute string equal to the fragment value. Other client behaviors are possible.

As a consequence, in some circumstances of URL redirection or display of intermediate pages (e.g., login screens) by the server, the browser may not be able to apply the fragment to the resource it ultimately receives from the server. Also, applications running on the server do not normally receive the fragment value with the rest of the URI, and are thus unable to take it into account when processing a request.

[edit] External links

In other languages