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, 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 or hash) character. The separator is not considered part of the fragment identifier.
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:
- RFC 5147 proposes a fragment identifier for text/plain documents, based on character and line positions and ranges within the document using the keywords "char" and "line". This example identifies lines 11 through 20 of a text document, for instance:
- Erik Wilde and Marcel Baschnagel of the ETH Zurich extend this to also identify fragments in plain text documents using regular expressions, with the keyword "match". For example, the following would find the case-insensitive text "RFC" anywhere in the document:
- K. Yee of the Foresight Institute proposes "extended fragment identifiers" delimited with colons and a keyword to differentiate them from anchor identifiers. A text search fragment identifier with "fragment specification scheme" id "words" is the first proposal in this scheme. The following example would search a document for the first occurrence of the string "some context for a search term" and then highlight the words "search term":
- Mozilla Foundation employee Gervase Markham has proposed a fragment identifier for searching, of the form
!s!search terms. The exclamation point is illegal in anchor tags, ensuring separation from that functionality. Adding a number after the s (
!s10!) indicates that the browser should search for the nth occurrence of the search term. A negative number (
!s-3!) starts searching backwards from the end of the document. A Greasemonkey script is available to add this functionality to compatible browsers.
- Google Webmaster Central has proposed using an initial exclamation point in fragment identifiers for stateful AJAX pages:
|This page uses Creative Commons Licensed content from Wikipedia (view authors).|