Text fragments in Firefox

Firefox, Firefox for Android Firefox, Firefox for Android अंतिम उद्दिनांकित किया गया: 1 week, 1 day ago
No one has helped translate this article yet. If you already know how localizing for SUMO works, start translating now. If you want to learn how to translate articles for SUMO, please start here.

Text fragments let you create links that highlight specific text on a webpage. This feature is especially useful for sharing or referencing specific parts of a webpage, as it works without requiring the webpage owner to modify the site. When someone clicks your link, their browser will automatically scroll to the target text and highlight it, making it easy to draw attention to the exact content you want to share.

Note: This article is designed for advanced users who want to create precise links that highlight specific text on webpages. The process involves modifying URL syntax, which might be challenging for some users. If you’re not comfortable with this, consider reaching out to someone familiar with web technologies for assistance.

Create and use text fragment URLs in Firefox

Creating text fragment URLs involves selecting the text you want to highlight and adding the right parameters to the URL. Here’s how you can do it step by step.

  • Find the specific text on the webpage that you want to highlight
  • Add a text fragment to the webpage URL using the following syntax:
[base-URL]#:~:text=[highlighted-text]

For example:

Text fragment example
https://support.mozilla.org/en-US/kb/firefox-dns-over-https#:~:text=address%20bar (scrolls to and highlights the first instance of the text address bar in the Firefox DNS over HTTPS document.)

Explanation of syntax

  • #:~: Indicates the start of the text fragment in the URL.
  • text= Specifies the exact text to highlight.

Optional parameters

To improve precision or handle ambiguous matches, use additional parameters:

  • textStart Defines the start of the highlighted text.
  • textEnd Defines the end of the highlighted text.
  • prefix- Text that immediately precedes the highlighted range.
  • -suffix Text that immediately follows the highlighted range.

Example with additional parameters:

link step 2

Practical examples

  • Highlight a single word:
    practical 1
    Highlights the word “example”.
  • Highlight a range of text:
    practical 2
    Highlights the text “Text Fragments are useful”.
  • Add context for ambiguous matches:
    practical 3
    Ensures the specific phrase is highlighted, even if similar text exists on the page.
Note: To use text fragments, make sure the person opening your link has a browser that supports them, like Firefox, Chrome, Edge, Safari, or Opera.

Common questions

What happens if the text I’m linking to changes?

If the text on the webpage is removed or significantly altered, the text fragment may no longer work. To make your link more reliable, consider using additional parameters like prefix or suffix to provide context for the browser. If no match is found, the link will default to scrolling to the top of the page or to a specified fallback fragment (if included).

Do text fragments work in all browsers?

Text fragments are supported by most modern browsers, including Firefox, Chrome, Edge, Safari, and Opera. However, users of older browsers or incompatible versions may not see the highlighted text. Make sure your recipients are using a supported browser for the best experience.

Can I use text fragments for non-text elements like images or videos?

No, text fragments only work with selectable text on a webpage. They cannot highlight or link to non-text elements such as images, videos, or interactive content.

क्या यह लेख उपकारी था?

Please wait...

These fine people helped write this article:

Illustration of hands

श्रमदान करें

Grow and share your expertise with others. Answer questions and improve our knowledge base.

Learn More