URI fragment
Thefragment of a URI is the last part of the URI, starting with the# character. It is used to identify a specific part of the resource, such as a section of a document or a position in a video. The fragment is not sent to the server when the URI is requested, but it is processed by the client (such as the browser) after the resource is retrieved.
In this article
Syntax
#fragmentfragmentA sequence of any characters.The exact format of the fragment is defined by the resource itself.
Description
Consider the following URL:
http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument#SomewhereInTheDocument is thefragment of the URL, which is an anchor to another part of the resource itself. An anchor represents a sort of "bookmark" inside the resource, giving the browser the directions to show the content located at that spot. In an HTML document, for example, the browser will scroll to the point where the anchor is defined. It can be theid attribute of an element, and the browser will scroll to that elementIn a video or audio document, it can be amedia fragment in the form of#t=..., which makes the video or audio start playing from that time.
There's a specialtext fragment feature that allows you to link to a specific part of a web page identified by its text content.
Examples
#syntaxThe browser will scroll to the element with the
id="syntax"in the document (which, for this page, is theSyntax heading).#:~:text=fragmentThe browser will highlight the text
fragmentin the document.#t=10,20The video or audio will start playing from the 10th second.
Specifications
| Specification |
|---|
| Unknown specification> # section-3.5> |