Testing

Scroll to Text Fragment: Browser Support, Syntax

Scroll to Text Fragment works in Chrome 80+, Edge 83+, Firefox 131+, Safari 16.1+, Opera 67+, and Samsung Internet 13+. See the full browser compatibility.

Author

Prince Dewani

May 6, 2026

Scroll to Text Fragment is a WICG URL directive that lets a link highlight a specific text snippet on a page through the #:~:text= syntax. It works in Chrome 80+, Edge 83+, Opera 67+, Samsung Internet 13+, Firefox 131+, and Safari 16.1+ on macOS and iOS, while Internet Explorer never added support.

This guide covers what Scroll to Text Fragment is, the browsers that support it, the syntax, how to create a link, the security restrictions, and the known issues.

What is Scroll to Text Fragment?

Scroll to Text Fragment is a Web Incubator Community Group (WICG) URL fragment directive that scrolls a page to and highlights a text snippet specified after #:~:text= in the URL. The browser strips the directive from document.URL after parsing, so the target page cannot read it.

Which browsers does Scroll to Text Fragment support?

Scroll to Text Fragment ships in every modern engine, with Chromium browsers leading the rollout, Safari following on macOS and iOS, and Firefox arriving last. Internet Explorer and Opera Mini never implemented the directive.

Loading browser compatibility data...

Scroll to Text Fragment compatibility in Chrome

Chrome supports Scroll to Text Fragment from Chrome 80 on Windows, macOS, Linux, ChromeOS, and Android. Chrome 74 to 79 had the directive disabled by default behind an Experimental Web Platform Features flag, and Chrome 73 and earlier did not support it.

Scroll to Text Fragment compatibility in Edge

Microsoft Edge supports Scroll to Text Fragment from Edge 83 on Windows, macOS, and Linux through the Chromium engine. Edge 79 to 82 had the directive disabled by default, and Edge Legacy 12 to 18 did not support it.

Scroll to Text Fragment compatibility in Firefox

Firefox supports Scroll to Text Fragment from Firefox 131 on Windows, macOS, Linux, and Android. Firefox recognizes the directive, scrolls to the match, and highlights the range. Firefox 130 and earlier ignore #:~:text= and scroll to the top of the document.

Scroll to Text Fragment compatibility in Safari

Safari supports Scroll to Text Fragment from Safari 16.1 on macOS, iOS, and iPadOS. Safari 18.2 added link generation through the Share menu, so users can copy a text fragment URL directly. Safari 16.0 and earlier on macOS, and the matching iOS Safari builds, ignore the directive.

Scroll to Text Fragment compatibility in Opera

Opera supports Scroll to Text Fragment from Opera 67 on Windows, macOS, and Linux through Blink. Opera 66 had the directive disabled by default behind an experimental flag, and Opera 65 and earlier did not support it. Opera Mini does not implement the feature on any version.

Scroll to Text Fragment compatibility in Samsung Internet

Samsung Internet supports Scroll to Text Fragment from Samsung Internet 13 on Galaxy phones and tablets. Samsung Internet 12 and earlier do not parse the directive and scroll to the top of the page.

Scroll to Text Fragment compatibility in Android Browser

The current Chrome for Android build supports Scroll to Text Fragment from Chrome 80 on Android 5.0 and later. The legacy Android Browser shipped with Android 4.4.4 and earlier did not implement the directive and ignores any #:~:text= value on the URL.

Scroll to Text Fragment compatibility in Internet Explorer

Internet Explorer 5.5 through Internet Explorer 11 never supported Scroll to Text Fragment. Microsoft has retired Internet Explorer, so any legacy intranet that needs deep linking into a specific phrase has to fall back to id-anchor fragments or a server-rendered hash that points at a known DOM node.

Note

Note: Scroll to Text Fragment behaves differently across Safari builds, Firefox versions, and Chromium flag states. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!

What is the syntax of Scroll to Text Fragment?

The directive sits after the regular URL fragment, separated by the :~: delimiter, and the value follows the text= keyword. The browser strips :~: and everything after it from the visible URL once the page loads.

  • Single phrase: #:~:text=hello%20world targets the first match of the phrase hello world on the page.
  • Range match: #:~:text=start%20here,end%20there highlights every character from the start phrase to the end phrase, including the phrases themselves.
  • Prefix and suffix: #:~:text=before-,target,-after lets you disambiguate repeated phrases by anchoring the match to the surrounding context. The prefix and suffix are not highlighted.
  • Multiple directives: Chain ranges with an ampersand, for example #:~:text=first&text=second, to highlight several phrases on the same page.
  • Reserved character encoding: Encode comma as %2C, hyphen as %2D, ampersand as %26, and space as %20 inside the directive value, otherwise the parser splits on those characters.
  • Combined with id fragment: #section-2:~:text=hello tells the browser to find the text inside the section-2 anchor first, then highlight the match.
...

What are the security restrictions of Scroll to Text Fragment?

The directive carries side-channel risk because the highlight signal can leak information about page content to the referring origin. The spec and every shipping engine apply four hard restrictions to keep that risk bounded.

  • User-initiated navigation only: The browser activates the text directive only on a top-level navigation that started from a click, a tap, or an address-bar entry. Scripted location.assign and history.pushState calls do not trigger the highlight.
  • Main frame only: Iframes, AMP frames, and ad slots ignore #:~:text=. The directive is dropped before the embedded document parses the URL, so a sub-frame cannot deep-link into its host.
  • Cross-origin opener isolation: A cross-origin link must use rel="noopener" on the anchor or pass noopener to window.open. Without it, Chrome and Edge silently strip the directive to prevent the opener from reading scroll position.
  • Stripped from document.URL: The browser hides the :~: portion from JavaScript, so the target page cannot read the fragment, log it, or echo it back to a server through document.URL or window.location.hash.
  • Document-Policy opt-out: A site can send Document-Policy: force-load-at-top in its response headers to opt the entire page out of text fragments. The browser then ignores every directive on inbound URLs.
...

What are the known issues with Scroll to Text Fragment?

The directive is stable on every modern engine, but the matching algorithm and the security boundary still produce predictable failures in production. Most issues trace back to encoding, block-level boundaries, or page mutation after publication.

  • Single block boundary: The matched range cannot cross a block-level element. A phrase that spans a paragraph break or a heading falls back to the prefix-only match, and a range across two paragraphs never highlights.
  • Stale links after content edits: If the page text changes by even one character, the link no longer matches. Editorial teams that auto-update copy break inbound text fragment links the moment they republish.
  • Single-page app navigation: Frameworks that intercept clicks with router-level navigation skip the user-initiated path. The directive then never fires, even though the URL contains it.
  • PDFs and non-HTML responses: The directive only applies to HTML documents. PDF viewers, plain text responses, and image responses ignore #:~:text= entirely.
  • Encoding traps: Forgetting to escape the comma in a phrase splits the directive into a range, and forgetting to escape the hyphen turns the start phrase into a prefix. Both produce an empty match with no error.
  • Highlight color clashes: The default browser highlight color is yellow on Chromium and pink on Safari. Pages with similar background colors render the highlight invisible, and there is no CSS hook to restyle it across engines.

In my experience, the trap that bites teams hardest is shipping text fragment links from a marketing CMS that auto-rewrites apostrophes and dashes to typographic versions on publish, which silently breaks every inbound link the moment the post goes live.

Citations

All Scroll to Text Fragment version numbers and platform notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests