Thursday, July 30, 2020
Text Fragments: Highlight text in a page you are linking to
Text fragments are a new feature that you can include in URLs to highlight specific text in the page you are linking to. You can read more about them here (or read the specification for them here), but essentially they let you link to a page and when the user arrives at the page they will see a text fragment highlighted. The spec gives you some flexibility for finding particular fragments of text based on some start and end searches, but the basics are that you add #:~:text=text%to%highlight at the end of your URL and everything just works (assuming your browser supports it).
Note that this is for highlighting a specific block of text, not for finding all occurrences in text. I can highlight a specific phrase. For example, this link highlights a sentence on a post about Docker and port forwarding).