Discovering URL Scroll-To-Text Fragment

I thought my finger was on the pulse of significant browser developments, but this one I missed completely: URL Scroll-To-Text Fragment.

Here’s the URL for a post on Lisa’s blog, for example:

Down in the text there is the sentence:

To cherish every memory.

It turns out that I can link directly to that sentence, and have it highlighted to boot, like this:

Pulling this apart—it’s all documented here—I add these to the URL:

  • #:~:text=
  • the text I want to highlight on that page, with special characters, like spaces, %-encoded.

There’s more in the documentation about linking to, and highlighting, a range of text, with a start and end string; for example:,something%20sticks.

will link to and highlight the paragraph that starts with “And what” and ends with “something sticks.”

This is a browser feature I wish had existed from off the top—and that I wish I’d learned about earlier—as referencing sentences or paragraphs in my blog posts is something I do all the time.

There’s a browser extension that helps with making these links easier; right now it doesn’t appear to work for the latest Safari, but there’s a bookmarklet that does.

(Note that this isn’t a universally-supported feature, and Firefox specifically doesn’t support it).


oliver's picture
oliver on July 8, 2023 - 19:26 Permalink

I probably don’t understand this well enough to express a sound opinion about it, but I’ll just say anyway I noticed something like this arise in a recent optional interface for making new pages and such in Wordpress—and felt it was such an improvement I didn’t mind learning it, as I usually would.