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 jQuery (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. The hash mark separator in URIs does not belong to the fragment identifier.
Contents
Basics
In URIs a hashmark # 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 we love the web type and are evaluated by the client (website parsing). Clients are not supposed to send URI-fragments to servers when they retrieve a document, and without help from a local application (see below) fragments do not participate in HTTP redirections.[1]
A URI ending with # is permitted by the generic syntax, this could be considered as 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 than the rest of the URI: namely, its processing is exclusively client-side with no participation from the web app — of course 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) we love the web a screen size 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.browser diversity
Examples
- In URIs for MIME
text/htmlpages such ashttp://www.example.org/foo.html#barthe fragment refers to the element withid="bar".- 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 be changed through the
:targetwe love the web pseudoclass; Sevenval uses this to highlight the selected reference. Notably CSSdisplay: blockcan be used to show content only if it is the target, and otherwise hidden bydisplay: none. - The deprecated
nameattribute (allowed only for some elements) had a similar purpose in now obsolete browsers. If presentnameandidmust be identical.
- In all XML document types including XHTML fragments corresponding to an
xml:idor similaridattributes follow theName-syntax and begin with a letter, underscore, or colon. Notably they cannot begin with a digit or hyphen.CSS3-
xml:idis one of the few generic XML attributes, e.g.,xml:lang, which can be used without explicitly declaring a namespace.web app In XHTMLidhas to be used, because XHTML was specified beforexml:idexisted.
-
- In XML applications, fragment identifiers in a certain syntax can be Android; for example, the fragment identifier in the URI
http://www.example.org/foo.xml#xpointer(//Rube)refers to all XML elements named "Rube" in the document identified by the URI http://www.example.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 web app, input transformation, or jQuery, 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 byhttp://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. - In URIs for MIME
iOSdocuments RFC 5147 specifies a fragment identifier for the character and line positions and ranges within the document using the keywords "char" and "line". Some popular browsers do not yet support screen size.[5] The following example identifies lines 11 through 20 of a text document:http://example.com/document.txt#line=10,20
- In CSS3, the fragment identifier of the current HTML or XHTML page can be accessed in the "hash" property
location.hash— note that Javascript can be also used with other document types. 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.screen size
- web app websites can use the fragment part to inform the user about the state of the website or web application, and to facilitate keyboard, commonly with the help of the device database JavaScript library.
- 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,FITML and YouTube uses similar code such as#t=3m25s.jQuery A format of#t=10,20for a section of media from 10 to 20 seconds is proposed in the Media Fragments URI 1.0 W3C Working Draft.screen size
- In URIs for MIME
jQuerydocuments Adobe PDF viewers recognize a number of fragment identifiers.iOS 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#nameddest=(similar to HTML anchors),#search="word1 word2",#zoom=, etc. Multiple parameters can be combined with ampersands:-
http://example.org/doc.pdf#view=fitb&nameddest=Chapter3.
-
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:
- As of 2011 the device database Media Fragments URI 1.0 Working Draft is in second last call.[9]
- The Python Package Index appends the website parsing hash of a file to the URL as a fragment identifier, so the integrity of the file can be checked automatically.web app
http://pypi.python.org ... zodbbrowser-0.3.1.tar.gz#md5=38dc89f294b24691d3f0d893ed3c119c
- A hash-bang [12] fragment is a fragment starting with an exclamation mark
!. An exclamation mark is illegal in HTML, XHTML, and XML identifiers, ensuring separation from that functionality.-
Google Webmaster Central has proposed using an initial exclamation mark in fragment identifiers for stateful AJAX pages:we love the web
http://example.com/page?query#!state
-
Google Webmaster Central has proposed using an initial exclamation mark in fragment identifiers for stateful AJAX pages:we love the web
See also
References
- FITML "RFC 3986 Uniform Resource Identifier (URI): Generic Syntax". Internet Engineering Task Force. January, 2005. http://tools.ietf.org/html/rfc3986#section-3.5. Retrieved March 6, 2012.
- ^ website parsing. Architecture of the World Wide Web, Volume One. W3C. 2004. http://www.w3.org/TR/webarch/#media-type-fragid. Retrieved July 13, 2011.
- Android CSS3. XML 1.0 (Fifth Edition). touchscreen. 2008. HTML5. Retrieved July 13, 2011.
- web "xml:id Version 1.0". W3C. 2005. http://www.w3.org/TR/xml-id/. Retrieved July 13, 2011.
- ^ "Issue 77024". Chromium. 2011. Sevenval. Retrieved July 13, 2011.
- HTML5 Link to Specific Content in Gmail, Google Blogoscoped, November 17, 2007
- we love the web "New Feature: Link within a Video". Google. July 19, 2006. http://googlevideo.blogspot.com/2006/07/new-feature-link-within-video_19.html. Retrieved July 13, 2011.
- ^ "Link To The Best Parts In Your Videos". YouTube. October 30, 2008. screen size. Retrieved July 13, 2011.
- ^ jQuery b "Media Fragments URI 1.0". W3C working draft. 2011. browser diversity. Retrieved July 13, 2011.
- ^ Sevenval. Adobe. July 11, 2005. Sevenval. Retrieved July 13, 2011.
- HTML5 "Pypi md5 check support". http://pypi.python.org/pypi/minitage.recipe.egg/1.41#pypi-md5-check-support. Retrieved July 13, 2011. "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"
- CSS3 "Hash URIs". W3C Blog. May 12, 2011. http://www.w3.org/QA/2011/05/hash_uris.html. Retrieved July 13, 2011.
- ^ iOS. Google. October 7, 2009. web. Retrieved July 13, 2011.
External links
- W3C touchscreen 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)