copy link with text highlighted in a website

2 min read  •  18 Feb 2023
Views:

Ever wondered, when you search for some query on google, you get a nice minimal answer from a long blog post or article, and when you open that article that particular text or group of text gets highlighted. In case you haven't seen that here's a demo-


copy-link-highlight-text-demo

How does it work?

For the above demo, the link is -

https://observatoireprevention.org/en/2021/03/09/why-do-the-japanese-have-the-highest-life-expectancy-in-the-world/#:~:text=Japanese%20life%20expectancy&text=This%20low%20mortality%20is%20mainly,and%203.7%25%20for%20women).

If we look closely, the link has #:~:text= at the end of the website path. So the structure of url to form such a link is-

# structure of url
https://yourwebsite.com/path/to/article/#:~:text=the text you want to highlight

And here is a demo url, where you can verify the above - https://akulsrivastava.com/about#:~:text=Hey%20there%2C%20I%20am%20Akul


  1. Go to the website and select the text which you want to highlight.
  2. Right-click on the text
  3. Select Copy link to highlight
how-to-copy-highlight-link

Highlighting multiple texts

To get the link with multiple texts highlighted, manual effort is needed i.e. structuring the url by ourselves in the following format-

https://website.com/your/path/#:~:text=this is text 1&text=this is text 2

Demo Url - https://akulsrivastava.com/about#:~:text=Hey there, I am Akul&text=I also like to explore opensource projects