I want to be able to specify a text snippet in a URL fragment to link directly to it

Submitted by Raphael Louis Andress

This idea is currently being discussed.

I want every browser to support text fragment URLs, allowing me to link directly to a specific piece of text on any web page without requiring the page to have a matching id attribute.

Today, deep-linking within a page relies entirely on anchor IDs placed by the page author. If the destination page has no id on the paragraph or sentence I want to share, I cannot create a direct link to it. This makes sharing precise references from long articles, documentation pages, or search results unnecessarily difficult.

The WICG Scroll to Text Fragment proposal introduces a #:~:text= syntax in URL fragments. A link like:

https://example.com/article#:~:text=some%20quoted%20phrase

would cause the browser to scroll to and highlight the first occurrence of the quoted phrase on the page, regardless of whether the author added any anchors.

This capability is especially valuable for:

Cross-browser standardization of text fragments would make this a reliable tool for everyone on the web. A consistent JavaScript API to detect, create, and manipulate text fragment URLs would make it even more powerful for developers building citation, annotation, and bookmarking tools.

Tagged
URLs HTML
Votes
0
What are votes for and how are they tallied?