• In URIs for MIME
text/html pages such as http://www.example.org/foo.html#bar the fragment refers to the element with id="bar". • Graphical Web browsers typically scroll to 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 contents. • The appearance of the identified element can be changed through the :target
CSS pseudoclass.
Wikipedia uses this to highlight the selected reference. Notably CSS display: block can be used to show content only if it is the target, and otherwise hidden by display: none. • The name attribute of the element served the same purpose, but is now obsolete in favor of the id attribute, which can be applied to any element. • In all
XML document types including
XHTML fragments corresponding to an xml:id or similar id attributes follow the Name-syntax and begin with a letter, underscore, or colon. Notably they cannot begin with a digit or hyphen. • xml:id is one of the few generic XML attributes, e.g., xml:lang, which can be used without explicitly declaring a namespace. In XHTML id can also be used and seems to be preferred, because XHTML was specified before xml:id existed. • In XML applications, fragment identifiers in a certain syntax can be
XPointers; 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
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. • In URIs for MIME
text/plain documents
RFC 5147 specifies a fragment identifier for the character and line positions and ranges within the document using the keywords "char" and "line", and an integrity check can be added, either "length" or "md5". Browser support seems lacking. The following example identifies lines 11 through 20 of a text document: • http://example.com/document.txt#line=10,20 • In URIs for MIME
text/csv documents,
RFC 7111 specifies a fragment identifier as a selector for rows, columns, and cells using the keywords "row" , "col", and "cell", For example: • http://example.com/data.csv#row=4 – Selects the 4th row. • http://example.com/data.csv#col=2 – Selects 2nd column. • http://example.com/data.csv#row=5-7 – Selects three consecutive rows starting with 5th row. • http://example.com/data.csv#row=5-* – Selects all rows starting with 5th row. • http://example.com/data.csv#cell=4,1-6,2 – Selects a region that starts at the 4th row and the 1st column and ends at the 6th row and the 2nd column. • In URIs for MIME audio/*, image/*, video/* documents, very few have defined fragments or fragment semantics. The Media Fragments URI 1.0 (basic) syntax supports addressing a media resource along two dimensions (temporal and spatial) using the keywords t and xywh, and Media Fragments 1.0 URI (advanced) adds track and id. Therefore, one can use the following media fragments URI in the src attribute of the audio or video
HTML5 element: • http://example.com/foo.mp4#t=10,20 (this indicates the time interval starting at 10 seconds and ending before 20 seconds) • http://example.com/bar.webm#t=40,80&xywh=160,120,320,240 • The specification also allows for specifying hours, minutes (must be 2 digits), and seconds (must be 2 digits) using colons, and milliseconds using a decimal point. Other time schemes may also be able to be specified through prefixes, with npt: (Normal Play Time) being the default. • 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 #01h25m30s to start playing at the specified position, and
YouTube uses similar code such as #t=3m25s. • In
JavaScript, the fragment identifier of the current HTML or XHTML page can be accessed in the "hash" property location.hash – 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. •
Adobe Flash websites can use the fragment part to inform the user about the state of the website or
web application, and to facilitate
deep linking, commonly with the help of the SWFAddress
JavaScript library. • A URI that links to a
JSON document can specify a pointer to a specific value. • For example, a URL ending in #/foo could be used to extract the value from a key-value pair in a document beginning with { "foo": ["bar", "baz"], ... } • In URIs for MIME
application/pdf documents PDF viewers recognize a number of fragment identifiers. For instance, a URL ending in .pdf#page=35 will cause most readers 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. • In
SVG, fragments are allowed to specify arguments such as viewBox(), preserveAspectRatio(), and transform(). • To identifying a text snippet within the text, the fragment ":~:text=[prefix-,]textStart[,textEnd][,-suffix] will highlight "textStart", or forward to "textEnd" if applied. The prefix and suffix will not be highlighted but helps finding the text on the page. Example: https://en.wikipedia.org/w/index.php?title=Cat&oldid=916388819#:~:text=Claws-,Like%20almost,the%20Felidae%2C,-cats ==Proposals==