On this page
- Key Takeaways
- Build a text fragment link
- Prepare the page and fallback
- Test text fragment links on mobile
- Verify support before the campaign
- Run the link checks
- Check common matching problems
- Changed or repeated wording
- Encoded characters
- Sign-in, redirects, and dynamic content
- Check keyboard and screen-reader usability
- Common Mistakes
- Best Practices
- Conclusion
A text fragment can send a shopper to a particular product detail or promotion term instead of just the top of a page. Before a seasonal promotion goes live, test text fragment links on mobile: the passage may have changed, the page may load it too late, or the browser may not support the feature.
This guide explains how to build a link and check it with real devices. Current browser support could not be verified, and the example links could not be tested in this environment. Before publishing, consult current official browser documentation and complete the device checks below.
Key Takeaways
- A text fragment uses
#:~:text=followed by URL-encoded text to identify a passage. - Treat scrolling and highlighting as enhancements, not guarantees. Provide a useful ordinary page link or a visible heading as a fallback.
- Test the final link on the mobile browsers and in-app browsers your shoppers use, including signed-out and dynamically loaded pages.
- Check that the passage makes sense without highlighting and is reachable and understandable with a keyboard and screen reader.
Build a text fragment link
Suppose a fictional product page contains this exact sentence:
Keeps drinks cold for 24 hours.
An illustrative link to that sentence is:
https://shop.example/products/winter-flask#:~:text=Keeps%20drinks%20cold%20for%2024%20hours
The part before # is the ordinary page URL. The fragment directive begins with :~:text=; its value identifies the text to find. Spaces in the example are encoded as %20. The example domain is fictional, so replace the entire page URL and passage with your own published content.
You can combine a conventional heading anchor with a text directive. For example, if the page actually has an element with the ID specifications, this link supplies both:
https://shop.example/products/winter-flask#specifications:~:text=Keeps%20drinks%20cold%20for%2024%20hours
Check the heading anchor separately; an invented or changed ID will not provide a reliable fallback. Depending on the browser and page, a text match may be highlighted and scrolled into view, but do not assume either outcome without testing.
Advertisement
Prepare the page and fallback
- Choose a stable passage. Use wording that is distinctive enough to identify the intended detail and unlikely to change during the campaign. For promotion terms, include enough surrounding context that the condition is not misleading.
- Confirm the published page. Check the live URL, not just a preview. Confirm that the passage appears for the intended audience, including any regional or language variants.
- Provide a visible destination. Prefer a descriptive heading near the passage and, where your site supports one, an ordinary anchor link to that heading. Otherwise, link to the page normally and tell readers which section to find.
- Keep essential context on the page. A shopper who lands at the top should still be able to find the specifications or full terms. Never make highlighting the only way to understand an offer.
For example, link to a visible “Promotion terms” heading and direct readers to the eligibility paragraph beneath it. If the page has no stable heading anchor, use the ordinary policy-page URL as the fallback.
Test text fragment links on mobile
Verify support before the campaign
Consult current official documentation for each browser in your test plan, and record the browser and operating-system versions. Do not infer support solely from a browser name: mobile versions and in-app browsers can behave differently. This article does not establish a current support list.
Choose devices based on your audience and available equipment. Include an iPhone and an Android phone where practical, plus the browsers and campaign entry points you expect shoppers to use. An in-app browser opened from an email or social app is a separate test from the phone's standalone browser.
Run the link checks
For each device and browser, use the final campaign URL rather than a link reconstructed from memory:
- Open the link from the intended source, such as a test email or campaign preview. Note whether it opens in an app, an in-app browser, or a standalone browser.
- Check whether the correct page opens and whether the intended passage is visible and highlighted. Record separately if the page opens but does not scroll or highlight.
- Read the surrounding content. Confirm that the highlighted wording identifies the correct product, variant, offer, dates, and conditions where applicable.
- Open the ordinary fallback link and confirm that a shopper can find the same information without relying on the highlight.
- Repeat in a fresh or signed-out session. If relevant, repeat after sign-in, after selecting a product variant, and for each supported region or language.
- Record the device, operating-system version, browser or app version, starting context, result, and any workaround. Retest after content or page-template changes.
If a supported browser still misses the passage, check for redirects, consent dialogs, client-side rendering, and the timing of content loading. A link may reach the page without finding text that appears later. Have the site team make important terms available on the initial page where possible, and retain the fallback rather than assuming a delayed match will occur.
Advertisement
Check common matching problems
Changed or repeated wording
A text fragment depends on page text, not on a permanent identifier for a sentence. A copy edit, localization, changed variant, or revised offer can make a link miss its intended passage. Recheck links whenever the relevant content changes.
If the same phrase appears more than once, use a longer distinctive passage or add surrounding context. Text-fragment syntax also supports a start and end of a range and optional prefix or suffix context; use those only after checking the syntax in current browser documentation and testing the complete link. Do not assume an ambiguous phrase will land on the occurrence you intended.
Encoded characters
Encode the passage as a URL component rather than inserting characters that have special URL meanings. For example, the text Save 20% on cups & lids becomes:
Save%2020%25%20on%20cups%20%26%20lids
Here %25 represents the literal percent sign and %26 represents the ampersand. Use a URL-encoding tool or your publishing system's encoder for non-ASCII characters as well. Encode the text value, not the #:~:text= syntax, and avoid encoding an already encoded value a second time. Test the final URL after it has passed through the email or campaign platform.
Sign-in, redirects, and dynamic content
A fragment does not grant access to restricted content. If a page requires sign-in, shoppers may encounter a login screen, and a redirect may not preserve the fragment. Test the complete journey with an appropriate test account; do not put credentials or private information in the URL.
Also test pages where text appears only after a consent choice, interaction, or JavaScript request. If the target is unavailable when the browser tries to find it, the page may open without the intended landing behavior. A visible heading and ordinary link remain important fallbacks.
Check keyboard and screen-reader usability
On the destination page, use a keyboard to navigate through links and controls and check that focus remains visible. With a screen reader such as VoiceOver on iPhone or TalkBack on Android, navigate by headings or page content to the target section. Confirm that the heading, target passage, and nearby conditions make sense when read in order.
Do not assume that a visual highlight moves keyboard focus or announces the passage to a screen reader. Test the actual experience, including the fallback, and involve your accessibility team or affected users where possible. If shoppers cannot locate or understand the terms without the highlight, revise the page before promoting the link.
Common Mistakes
- Linking to a phrase that appears in several places: Use distinctive wording and verify the landing position.
- Testing only while signed in: Repeat the journey in a fresh session and account for login redirects.
- Assuming a highlight proves the offer is clear: Read the surrounding eligibility rules and conditions too.
- Relying on a fragment as the only navigation: Supply a normal page or heading link.
- Publishing based on a desktop preview alone: Test the final campaign link in the mobile and in-app contexts shoppers will use.
Best Practices
Assign an owner to retest campaign links when product copy, policy wording, page templates, or regional content changes. Keep a small record of tested URLs and device results, and check current official browser documentation again before each promotion. If a destination or its support is uncertain, use the ordinary link and a clear instruction to find the relevant section.
Conclusion
A text fragment can make a product detail easier to find, but the page and its fallback must work independently of the highlight. Verify current support, test the final link on representative mobile devices, and recheck it whenever the target content changes.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.