From Seo Wiki - Search Engine Optimization and Programming Languages
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.
- In HTML applications,
http://www.foo.org/foo.html#barrefers to the element with the
idattribute that has the value
id="bar") in the document identified by the URI
http://www.foo.org/foo.html, which is typically the location from which the document would be obtained via the Internet. The deprecated
nameattribute can also be used for this purpose in the same manner.
- If the targeted element is located in the current document, a user agent (e.g., Web browser) may simply focus the targeted element (e.g., by scrolling the document view to it) without having to reload it. Otherwise, the user agent will need to first retrieve the document and load the relevant element before it can focus the element.
- Graphical Web browsers typically position pages so that the top of the element identified by the fragment id is aligned with the top of the viewport; thus fragment identifiers are often used in tables of content and in permalinks.
- The appearance of the identified element can also be changed through the
:targetCSS pseudoclass; Wikipedia uses this to highlight the selected reference.
- With the rise of AJAX, some websites use fragment identifiers to emulate the back button behavior of browsers for page changes that do not require a reload, or to emulate subpages. (For example, GMail uses a single URL for almost every interface – mail boxes, individual mails, search results, settings – the fragment is used to make these interfaces directly linkable.)
- Other websites use the fragment part to pass some extra information to scripts running on them – for example, Google Video understands permalinks in the format of
#01h25m30sto start playing at the specified position, and YouTube uses similar code such as
- Adobe PDF viewers recognize a number of fragment identifiers. For instance, a URL ending in
.pdf#page=35will cause Adobe Reader to open the PDF and scroll to page 35. Several other parameters are possible, including
#namedest=(similar to HTML anchors),
#zoom=, etc. Multiple parameters can be combined with ampersands. For example:
- In XML applications, fragment identifiers in a certain syntax can be XPointers; for example, the fragment identifier in the URI
http://www.foo.org/foo.xml#xpointer(//Rube)refers to all XML elements named "Rube" in the document identified by the URI http://www.foo.org/foo.xml. An XPointer processor, given that URI, would obtain a representation of the document (such as by requesting it from the Internet) and would return a representation of the document's "Rube" elements.
- 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#broaderidentifies 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.
- The Python Package Index appends the MD5 hash of a file to the URL as a fragment identifier, so the integrity of the file can be checked automatically.
http://pypi.python.org ... zodbbrowser-0.3.1.tar.gz#md5=38dc89f294b24691d3f0d893ed3c119c
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:
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. This can be remedied by replacing
# in the URL to be redirected with
%23, the percent-encoded value of
#. 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.
- ↑ Link to Specific Content in Gmail, Google Blogoscoped, November 17, 2007
- ↑ New Feature: Link within a Video, Official Google Video Blog, July 19, 2006
- ↑ http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
- ↑ http://pypi.python.org/pypi/minitage.recipe#pypi-md5-check-support
- ↑ http://www.faqs.org/rfcs/rfc5147.html
- ↑ doi:10.1145/1083356.1083398
- ↑ http://zesty.ca/crit/draft-yee-url-textsearch-00.txt
- ↑ http://www.gerv.net/software/fragment-search/
- ↑ Proposal for making AJAX crawlable, Official Google Webmaster Central Blog, 2009-10-07
- Architecture of the World Wide Web, Volume One 3.2.1. Representation types and fragment identifier semantics
- RFC 2396 4.1. Fragment Identifier
- RFC 3986 3.5. Fragment
- W3C Media Fragments Working Group, establishing a URI syntax and semantics to address media fragments in audiovisual material (such as a region in an image or a sub-clip of a video)de:Fragmentbezeichner