Web APIs

URL Fragment Text Directives

Checking compatibility...

URL Fragment Text Directives allow web developers to specify instructions in URL fragments for user agents to process, such as highlighting specific text on a page or scrolling to a specific text fragment.

Basic Text Fragment

Create links that highlight specific text when visited. This example shows how to use the :~:text= directive to make browsers automatically find, scroll to, and highlight exact phrases on a webpage - making it easy to direct readers to the most important information.

=
=
=
=
=
=

Output

Click Run to see output...

Advanced Text Fragments

Target text precisely even when there are multiple identical matches on a page. This example demonstrates how to use context parameters (prefix and suffix) to disambiguate similar text, and how to highlight content that spans across multiple HTML elements - ensuring your links always point to exactly the right content.

=
=
=
=
=
=

Output

Click Run to see output...

Fragment URL Creation

Build properly formatted text fragment URLs with this interactive tool. This example helps you create shareable links that highlight specific text, handling all the necessary encoding and syntax requirements automatically - making it easy to generate links for social media, documentation, or educational purposes.

=
=
=
=
=
=

Output

Click Run to see output...