Text fragments in the browser URI fragment

Posted . Visible to the public.

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)

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