Text location hashes are useful when pasting a URL to a page without anchors.
Here are some live examples:
- https://docs.gtk.org/Pango/pango_markup.html#:~:text=insert_hyphens
- https://docs.gtk.org/gtk4/class.TextTag.html#properties:~:text=TextTag%3Ainsert%2Dhyphens
These are escaped by Stack Overflow. When you directly click the link, the highlight doesn't work. A user has to copy the URL and paste to a browser location bar manually. In the edit preview it is fine, but in normal view mode, it is escaped: :~:text
become :%7E:text
, and the anchors ineffective.
:~:text
delimiter. Such URLs are, currently, only supported in Chromium. I don't know if other browsers are moving to support them. That such URLs are not currently functional in posts is a bug/FR in Chromium, not Stack Exchange, IMO. What's preventing the URLs from being functional is that SE's backend percent encodes the~
to%7E
. That's perfectly valid and common. If Chromium wants to use:~:text
, then Chromium should decode the%7E
, which is explicitly permitted.<a href="foo.com:~:text">foo</a>
instead of[foo](foo.com:~:text)
, the tilde symbol is preserved and scroll to text fragments will work. Just tried it myself and it indeed works with anchor tags. See my test answer here: meta.stackexchange.com/a/357228/299995