Text fragments in the browser URI fragment

Updated . Posted . Visible to the public. Repeats.

Text fragments allow linking directly to a specific portion of text in a web document, without requiring the author to annotate it with an ID, using particular syntax in the URL fragment. Supporting browsers are free to choose how to draw attention to the linked text, e.g. with a color highlight and/or scrolling to the content on the page. This is useful because it allows web content authors to deep-link to other content they don't control, without relying on the presence of IDs to make that possible. Building on top of that, it could be used to generate more effective content-sharing links for users to pass to one another.

You might know this feature from the Google search, where the preview text in the search is highlighted in the HTML after you followed the link.

Example: https://example.com/#:~:text=for%20use%20in Show archive.org snapshot
Browser Support: https://caniuse.com/?search=text%20fragment Show archive.org snapshot (good global support in July 2025)

Tip

In Chrome you can right-click on any text selection and choose Copy link to highlight. This copies a URL with the scheme above.

Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2024-11-29 10:26)