You can easily create a link (or URL) with a text fragment by simply entering the destination page URL and the target text.
* This is a tool for those who want to set up text fragments themselves.
Text fragment settings
Required
- Target URL
- Start Text
Optional
- End Text
- Prefix Text
- Suffix Text
- Fallback ID
- The code will be output
- Preview
-
[ A link for preview will be displayed here ]
* If you cannot identify the link destination text, please double-check the input fields (e.g., if you have entered the wrong field or forgotten to delete something).
* This preview link has target="_blank" and rel="noreferrer noopener".
How to use this tool
- In the "Target URL" field, enter the URL of the linked page. In the "Start Text" field, enter the text that will be the destination on the linked page. (e.g., if you want to scroll to the part of the linked page that says "Tag Index," enter that text in the "Start Text" field.)
- If the link destination text is long (e.g., if you want to specify an entire paragraph or multiple paragraphs), you can specify the entire range of text as the link destination by entering the beginning of the text in the "Start Text" field and the end of the text in the "End Text" field.
- If you cannot identify the linked text with the above settings alone, enter the text immediately before the linked text in the "Prefix Text" field or enter the text immediately after the linked text in the "Suffix Text" field to narrow the search. (It is also possible to enter the text immediately before and immediately after at the same time.)
- The text you enter will automatically be percent-encoded.
- If an ID is specified for the container of the target text, you can enter that ID in the "Fallback ID" field. This ID will be a fallback for browsers that do not support text fragments.
- If you are using a text fragment to link to another site (different origin), you must specify rel="noopener" in the a element.
- The syntax of a text fragment is as follows. Each piece of text is separated by a comma (,), and a hyphen (-) is placed at the end of the Prefix Text and at the beginning of the Suffix Text. Text other than the Start Text can be omitted.
https://example.com/abc.html#:~:text=PrefixText-,StartText,EndText,-SuffixText - As of July 2024, Chrome, Edge, and Safari support text fragments. Chrome and Edge have a feature that automatically creates URLs with text fragments (Right-click on the selected text => Copy link). However, it seems that you cannot make detailed settings.
- To use this tool, you must enable JavaScript in your browser.
Reference list
The following sites can help you create text fragments.