Textual content fragments are a manner for internet hyperlinks to specify a phrase or phrase a browser ought to spotlight on the vacation spot web page. Google Chrome added help for them in model 80 (launched in February 2020).
For instance, opening the hyperlink oleb.internet/2020/swift-docker-linux/#:~:textual content=working,container in Chrome ought to spotlight the primary heading of the article:
The plain use case is engines like google: whenever you click on a hyperlink in a search consequence, the browser would robotically spotlight your search time period(s) on the vacation spot web page.
I’ve at all times needed this characteristic. I usually discover myself visiting a web page from a search engine, solely to instantly hit
However textual content fragments produce other makes use of past engines like google:
Linking to a specific sentence or paragraph of a protracted doc. I’d use this on a regular basis when linking to API documentation or discussion board posts. “Regular” URL fragments solely work for anchors the creator of the vacation spot web page created upfront, and readers often can’t see what anchor tags can be found on a web page.
Sharing a selected portion of a web page. Browsers may facilitate this by providing to incorporate a textual content fragment within the URL when sharing a hyperlink to a textual content choice.
Right here’s the pattern URL from above as soon as extra:
This half is the textual content fragment:
This fragment finds the primary point out of “working” (case-insensitive) on the web page and highlights all the things from that time till it finds “container”. There are a couple of extra variants of the syntax. Learn the textual content fragments draft spec for particulars.
Search phrases might include delicate info that customers don’t wish to share with the vacation spot server. For good purpose, engines like google stopped reporting the consumer’s search phrases within the referer header a very long time in the past as a part of the widespread transfer to HTTPS. It will be unhealthy if a brand new characteristic reintroduced this outdated knowledge leak.
doc.location.hash is clean as a result of Chromium stripped the textual content fragment away:
As a precaution, engines like google and comparable websites ought to in all probability solely embrace textual content fragments of their hyperlinks if the consumer’s browser helps the characteristic (
Chrome is at present the one browser with textual content fragment help. From what I’ve learn, the WebKit and Firefox groups are typically supportive of the thought however have some reservations about particular design selections.
I hope this or one thing prefer it turns into extensively supported within the close to future.