313

Today I noticed that some searches on Google gave me links to results with apparent instructions to highlight text.

Google brought me to What is the maximum size of a zip file on Windows 10 Pro 64... at the following url:

https://superuser.com/questions/1305867/what-is-the-maximum-size-of-a-zip-file-on-windows-10-pro-64-bit#:~:text=4%20GB%20size%20is%20a,about%2016%20exabytes%20size%20limitation

Google search for "win explorer max zip file size" - the Stack Exchange page in the result has highlights

I experimented a little bit further and this seems to be a feature of Google Chrome. It highlights text on the page if you append #:~:text=something to the URL. https://example.com/#:~:text=domain seems to work fine, but only on Chrome (Chrome Beta on the left, Firefox on the right).

The word "description" is highlighted on example.com

The word text together with different characters is a bit hard to google, so I couldn't find anything on the subject.

For finding out more information about these kinds of "URL-hacks" I want to know:
What is this feature of Google Chrome called?

6
  • 10
    i can find it and others in this website chromestatus.com/feature/4733392803332096 Commented Jun 2, 2020 at 21:58
  • 1
    I like it. I would hate it if the highlighting wouldn't go away when I scroll, but it does. Commented Mar 17, 2021 at 0:47
  • 1
    This Chrome add-on can remove those text fragments from the URL. Create a group matching all sites (.*) and inside match for (.*)#:~:.* and replace with $1. Commented Mar 17, 2021 at 0:50
  • 6
    @Makyen Would you mind to extend on why you think this question does not suit this site? I certainly think it's an edge case, however the name of the feature in question seems to be so unknown and yet needed for a technical implementation, which is what Stack Overflow can help with. Commented Sep 25, 2021 at 19:26
  • 6
    @palsch How is this a "a practical, answerable problem that is unique to software development"? You're literally asking "What is this feature of Google Chrome called?", which is "what's this feature of my browser called?" It could, alternately be paraphrased as "what is this portion of a URL called". Those are not programming questions. They are general technical questions. Closing this question doesn't mean it's not useful. It just means that it's not on-topic here. Commented Sep 25, 2021 at 20:30

1 Answer 1

337

Scroll To Text Fragment

OK, with the help of a friend and at the same time via a comment from Berto99 I found it:

Apparently this is a feature called Scroll To Text Fragment. It has been supported in all major browsers since 2024 (Baseline 2024).

There are quite nice examples in the "W3C Community Group Draft Report". More good examples can be found on Wikipedia.

Highlighting the first appearance of a certain text

Just append #:~:text=<text> to the URL. The text search is not case-sensitive.

Example: https://example.com#:~:text=domain The word "domain" is highlighted on example.com

Highlighting a whole section of text

You can use #:~:text=<first word>,<last word> to highlight a whole section of text.

Example: https://stackoverflow.com/questions/62161819/what-exactly-is-the-text-location-hash-in-an-url/62162093#:\~:text=Apparently,Wikipedia part of this very answer is highlighted

More advanced techniques

Sign up to request clarification or add additional context in comments.

19 Comments

The prefixing/suffixing does work. The example doesn't, though, because that text has not existed in Wikipedia since October 2019. This points out one of the dangers of using page content for scrolling & highlighting.
@mgkrebbs "one of the dangers of using page content for scrolling & highlighting" It's not a "danger" though, it's just a tradeoff. At worst, there would be no fine-grain positioning, that's it. Exactly as with normal #fragment links. Note: page structure can also change, rendering normal fragment positioning brittle, too. But that's fine. The fact that links break sometimes, doesn't mean they are "dangerous". It's an inherent, universal property of the web that we have to deal with anyway.
For anyone who came here like me wanting to know how to turn off this annoying feature, the flag in Chrome is called "Enable Text Fragment Anchor." -- chrome://flags/#enable-text-fragment-anchor
chrome://flags/#enable-text-fragment-anchor is unavailable in Chrome 85.
This is now supported in Safari on macOS, coming from Google search. Not sure exactly when this was enabled.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.