Originally published at: Text Fragments Enable Deep Linking on Web Pages - TidBITS
Wouldn’t it be nice if you could link to specific bits of text on a Web page rather than forcing people following your links to scan the page for whatever piece of information you’re trying to convey? With full support from major browser manufacturers appearing late last year, the Web has finally caught up with hypertext theory from the previous century.
The Long and Winding History of Text Fragment Linking
Sometime in the 1960s, hypertext pioneer Ted Nelson envisioned deep linking to specific pieces of text as a core feature of his proposed Project Xanadu system. (My first exposure to Xanadu came in the 1987 edition of his Computer Lib/Dream Machines from 1974, when I was working on my degree in hypertextual fiction at Cornell University. You can download the book in readable formats from the Internet Archive.)
From the early 1990s until recently, the only way to link to a specific part of a Web page was through a named anchor. If the page author inserted name="subhead1"
into an anchor link in their HTML, a URL like https://example.com/#subhead1
would cause browsers to scroll directly to that spot. Although we, as users, could copy those links or examine the HTML source of a document for named anchors that we could use when creating our own links, the vast majority of links point to the top of the destination page.
In 2020, to enable deep linking within pages, Google Chrome introduced the Scroll To Text Fragment (STTF) feature. It allowed URLs with a #:~:text=
parameter to link directly to any visible text on a page, so a URL like https://example.com#:~:text=specific%20phrase
would highlight and scroll to the text “specific phrase” on the page. The key benefit of the feature was that it didn’t require cooperation from the page author, and Google began using it to enhance the user experience within Google Search results.
Google also built the feature into the open source Chromium code. Over the next few years, that caused most Chromium browsers to adopt the feature, including Arc, Edge, Opera, Vivaldi, and others. Until very recently, Brave was a holdout because its senior privacy researcher believed that STTF introduces some privacy risks, but Brave now supports the feature in development builds. In what I consider a misguided move, Arc’s developers decided to encapsulate the long text fragment links in a custom shortlink redirected by a server at arc.net, perhaps to make the links more readable or increase privacy. Text fragment URLs may be long, but they allow users to preview the hostname of the destination and won’t break if the arc.net redirection service disappears.
Until late 2024, Mozilla and Apple chose not to support STTF due to additional privacy concerns and annoyance with Google’s use of its control over Chromium and Google Search to effectively dictate Web standards via deployment rather than consensus. Eventually, though, Mozilla and Apple bowed to market pressure, with partial support appearing in Firefox 131 in October 2024 and full support showing up in Safari 18.2 in December 2024. Firefox will now recognize text fragment links, scrolling to and highlighting them, though an add-on is necessary to create the links. Safari can both recognize and create links.
Following Text Fragment Links
As I noted, apart from the current version of Brave, all Web browsers that I’m aware of now support following text fragment links. When you click one—and you likely won’t realize that you’re doing so ahead of time—the specified page will load and scroll to the appropriate location, and the text included in the link will be highlighted. (In the current version of Brave, the page loads but doesn’t scroll or highlight any text—the link behaves like a regular link.)
Precisely what the highlight looks like can vary because page authors can style the highlighted text using the ::target-text
pseudo-element. It allows changing the color, background-color, text-decoration, text-shadow, stroke-color, fill-color, and stroke-width. However, most of the time, you’ll just see the styling used for the mark
HTML element: a purple (Chromium browsers), yellow (Safari), or orange (Firefox) highlight behind the text.
If the linked text changes, the highlighting will fail, but the page will still load.
Creating Text Fragment Links
Making your own text fragment links is simple—the hardest part is identifying the correct command in a contextual menu—you won’t find the relevant commands in the Edit menu. First, you select the desired text, then you Control-click and:
- In Safari, choose Copy Link with Highlight. This command is also available in Safari on the iPhone and iPad, as well as other browsers that use WebKit on these devices.
- In Chromium browsers other than Brave, choose Copy Link to Highlight.
- In Brave, after you have installed Google’s Link to Text Fragment extension, choose Copy Link to Selected Text.
- In Firefox or Orion, after you have installed Thomas Steiner’s Link to Text Fragment extension, choose Copy Link to Selected Text. (Firefox also has a hidden configuration tweak to enable native text fragment link creation.)
What if the word you select appears multiple times within the document? How will the browser know which one to highlight? The STTF spec includes prefix and suffix components in the URL—in essence, a few words on either side of the selected text that disambiguate it. In the article in the screenshot above, linking to the word “sidebar” automatically produces this URL, which includes three disambiguation words on either side of the target word:
https://tidbits.com/2025/04/10/new-organizational-features-in-photos-in-macos-15-sequoia/#:~:text=The%20next%20two-,sidebar,-sections%20in%20Photos
It’s not inconceivable that an ambiguous link could still be created, but the worst that would happen is that the browser would highlight the wrong text on the page. You’d have to work pretty hard to make that happen—linking to more than a few words should provide uniqueness.
One final tip. You can highlight multiple portions of a document by editing the text fragment URL and appending additional text=
elements, separated by an &
. It requires precise work to copy the text=
element from one URL and paste it into another, but the result may be worthwhile. Try it with this link below.
https://tidbits.com/2025/04/18/staying-the-course-after-35-years-of-tidbits/#:~:text=I%20believe%20we%20can%20best%20contribute%20by%20modeling%20the%20behavior%20we%20want%20to%20see%20in%20the%20world.&text=It%20means%20practicing%20kindness%2C%20decency%2C%20and%20respect%20whenever%20possible.
Can You Link Inside a PDF?
As welcome as text fragment links are, they aren’t necessary in most Web pages, which tend to be relatively short. However, PDFs are a different story. In “Add Protection from Scammers with Cyber Insurance” (11 April 2025), Glenn Fleishman linked to a Federal Trade Commission report to support his statement that Americans lost $12 billion to fraud in 2024. However, that’s a 92-page PDF, and it took me quite a few minutes to confirm the number during my edit pass.
In an ideal world, Glenn would have been able to use text fragment links to highlight the exact text he was referencing. Unfortunately, text fragment linking does not work in PDFs.
Happily, some research revealed that it is possible to link directly to the sixth page in a document, for instance, by appending #page=6
to its URL. I have updated the link in Glenn’s article to the URL below, which now scrolls to the page containing the data. It doesn’t highlight anything, but ending up on the page is far better than having to search or scroll through a lengthy PDF.
https://www.ftc.gov/system/files/ftc_gov/pdf/csn-annual-data-book-2024.pdf#page=6
Give Deep Linking a Try
Text fragment links represent a small but notable step forward in the evolution of the Web, finally realizing a part of Ted Nelson’s vision for hypertext and enabling precise navigation to specific content. Deep linking makes sharing information more efficient, improves the usability of lengthy documents, and helps readers focus on the most relevant content. I encourage you to start using text fragment links when you share information from the Web—people might not realize why the experience is better, but they’ll appreciate not having to hunt for the information you’re referencing.