How do text fragment links highlight a passage on a source page?

The Citead team, updated

In short. A text fragment link uses #:~:text= and optional range or context terms to identify the source passage a supporting browser highlights.

Definition: A text fragment link is a URL that identifies a passage through text placed after #:~:text=. A supporting browser can highlight the matching passage and scroll it into view, including text without an HTML element identifier.

Key facts

  • As of 17 October 2026, Google's web.dev documentation describes case-insensitive matching and optional context words for distinguishing repeated passages.
  • The WICG URL Fragment Text Directives draft makes start the only required text parameter; an optional end extends the match into a range.
  • Google's featured snippets documentation says automatic scrolling to a snippet's source passage requires no additional annotation by the website.

What does the URL syntax mean?

Google's web.dev guide gives this syntax. Square brackets mark optional parts and are omitted from an actual link:

#:~:text=[prefix-,]start[,end][,-suffix]

The # begins the URL fragment. The :~: delimiter introduces instructions for the browser, and text= introduces the text directive. With start alone, the browser searches for that text. With start,end, it searches for a passage beginning with start and ending with the following end match.

The text values use percent encoding. A space becomes %20; literal hyphens, ampersands and commas within a value also need encoding because those characters have roles in the directive syntax. Multiple text directives use & between them.

The WICG draft's context example illustrates a more selective match:

#:~:text=this%20is-,an%20example,-text%20fragment

This targets “an example” when preceded by “this is” and followed by “text fragment”. The prefix and suffix constrain the match and remain outside the highlighted passage. Whitespace is allowed between the context and target text.

How does the browser choose a passage?

The WICG matching algorithm searches rendered text for the first instance satisfying the directive's restrictions. Each text directive is searched independently. For a directive containing only start, a matching phrase must respect word boundaries; context terms can change where those boundaries apply.

Google's web.dev explanation shows how shortening a range can select an unintended passage: the first occurrence of the chosen ending can arrive before the intended ending. Longer start and end phrases, or surrounding context, distinguish occurrences.

Each individual start, end, prefix or suffix term must fit within a single uninterrupted block of text. A range between start and end can span several blocks. The guide demonstrates that The quick fails as a start term when an intervening block element separates those words.

What happens when the source page changes?

The WICG link lifetime discussion explains that edited or removed text can make a directive stale; such links degrade into ordinary page links. Google's web.dev guide also allows an element identifier before :~: to provide a fallback destination when the text stops matching.

For featured snippets, Google's Search Central documentation says a click goes to the top of the source page if the browser lacks the required technology or Google cannot confidently determine the passage's position.

FAQ

Does the source passage need an HTML identifier?

Google's web.dev example targets a heading without an id attribute. The text directive supplies the words to match.

Why does a repeated phrase highlight the wrong occurrence?

The WICG syntax description targets the first matching instance. You can add prefix- or -suffix context to distinguish the intended occurrence.

Can a website change the highlight's appearance?

Google's web.dev guide documents the CSS ::target-text pseudo-element for changing the text highlight's colors.

Sources

  1. Google web.dev, "Boldly link where no one has linked before: Text Fragments", updated 17 June 2020
  2. WICG, "URL Fragment Text Directives", Draft Community Group Report, 13 December 2023
  3. Google Search Central, "Featured snippets and your website", updated 10 December 2025

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark