DEV Community

Caleb Hearth
Caleb Hearth

Posted on • Originally published at calebhearth.com on

Highlighting Text in Links with Text Fragments

I’ve used URL text fragments in a few posts now and often use it outside of this blog to point someone to a particular piece of text on a page. They’re a really useful feature that allows you to create a URL that links not just to a page or an anchor on that page, but specifically to a bit of text that you’d like to call out to your audience.

The URL Fragment Text Directive is a W3C Draft, but has been around in at least some major browsers since 2020 and now has good support across Chrome, Edge, Safari, and Firefox as of this September. Firefox was the last straggler, with Safari joining the party in 2022.

Building URLs

Despite using Safari as my daily driver for various privacy, security, performance, and platform integration reasons, I still keep Chrome around for the occasional Google Meet call and for generating these links: highlight some text and right clip to copy a link to the highlight. Safari doesn’t have that feature yet unfortunately.

Read More

Top comments (0)