Log

いろいろ

Text fragments

今さらながらText fragmentsという機能を知りました。

Text fragments | MDN

Text fragments allow you linking directly to a specific portion of text in a web document, without requiring the author to annotate it with an ID, using particular syntax in the URL fragment.

IDが付与されたセクションだけでなく任意の文章へリンクできる機能。

従来のURL fragmentの場合。*1
https://mtzml.hatenablog.com/entry/2020/08/09/183036#New-Senstation

Text fragmentsの場合。
https://mtzml.hatenablog.com/entry/2020/08/09/183036#:~:text=一度きりの人生楽しむべきだよね絶対

複数マッチする場合は最初にマッチした文章へリンクする。
https://mtzml.hatenablog.com/entry/2020/08/09/183036#:~:text=水樹奈々

その場合は前後の文章の情報を与えることで特定の文章へリンクできる。
https://mtzml.hatenablog.com/entry/2020/08/09/183036#:~:text=が-,水樹奈々

シンタックスこちら

https://example.com#:~:text=[prefix-,]textStart[,textEnd][,-suffix]

大体のブラウザでは、選択範囲に対してコンテキストメニューから上記のURLを生成できます。

*1:画像ではNew Sensationというタイトルがヘッダーに隠れてしまっている。大体のWebページではこうなるのでもどかしい。