大网数据广告活动
Web 标准与前端开发

URI fragment

· 52CE 我爱测

The **fragment** 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; it is proces

The fragment 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; it is processed by the client (e.g., the browser) after the resource is retrieved.

Syntax

#fragment
  • fragment
    • : A 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 the fragment 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 the id attribute of an element, and the browser will scroll to that element. In a video or audio document, it can be a media fragment in the form of #t=..., which makes the video or audio start playing from that time.

There's a special text fragment feature that allows you to link to a specific part of a web page identified by its text content.

Examples

  • #syntax
    • : The browser will scroll to the element with the id="syntax" in the document (which, for this page, is the Syntax heading).
  • #:~:text=fragment
  • #t=10,20
    • : The video or audio will start playing from the 10th second; see Media fragments for more details.

Specifications

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。