URL Fragment Text Directives

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

Interfaces

FragmentDirective

A (currently) empty object. The existence of an object of this type in document.fragmentDirective is used for feature detection.

Extensions to other interfaces

Document.fragmentDirective

A property that returns a FragmentDirective object for the current document. Currently only used for feature detection.

CSS selectors

::target-text

Represents the text that has been scrolled to. It allows authors to choose how to highlight that section of text.

Specifications

Specification
URL Fragment Text Directives
# dom-document-fragmentdirective
URL Fragment Text Directives
# fragmentdirective
CSS Pseudo-Elements Module Level 4
# selectordef-target-text

Browser compatibility

api.Document.fragmentDirective

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
fragmentDirective
Chrome – Full support
Chrome 86 (Release date: 2020-10-20)
footnote Full support
Edge – Full support
Edge 86 (Release date: 2020-10-09)
footnote Full support
Firefox – Full support
Firefox 131 (Release date: 2024-10-01)
footnote Full support
Opera – Full support
Opera 72 (Release date: 2020-10-21)
footnote Full support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Chrome Android – Full support
Chrome Android 86 (Release date: 2020-10-20)
footnote Full support
Firefox for Android – Full support
Firefox for Android 131 (Release date: 2024-10-01)
footnote Full support
Opera Android – Full support
Opera Android 61 (Release date: 2020-12-07)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
Samsung Internet – Full support
Samsung Internet 14 (Release date: 2021-04-17)
footnote Full support
WebView Android – Full support
WebView Android 86 (Release date: 2020-10-20)
footnote Full support
WebView on iOS – Full support
WebView on iOS 18.4 (Release date: 2025-03-31)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

api.FragmentDirective

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
FragmentDirective
Chrome – Full support
Chrome 81 (Release date: 2020-04-07)
footnote Full support
Edge – Full support
Edge 83 (Release date: 2020-05-21)
footnote Full support
Firefox – Full support
Firefox 131 (Release date: 2024-10-01)
footnote Full support
Opera – Full support
Opera 68 (Release date: 2020-04-22)
footnote Full support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Chrome Android – Full support
Chrome Android 81 (Release date: 2020-04-07)
footnote Full support
Firefox for Android – Full support
Firefox for Android 131 (Release date: 2024-10-01)
footnote Full support
Opera Android – Full support
Opera Android 58 (Release date: 2020-05-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
Samsung Internet – Full support
Samsung Internet 13 (Release date: 2020-12-02)
footnote Full support
WebView Android – Full support
WebView Android 81 (Release date: 2020-04-07)
footnote Full support
WebView on iOS – Full support
WebView on iOS 18.4 (Release date: 2025-03-31)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

css.selectors.target-text

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
::target-text
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote Full support
Edge – Full support
Edge 89 (Release date: 2021-03-04)
footnote Full support
Firefox – Full support
Firefox 131 (Release date: 2024-10-01)
footnote Full support
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote Full support
Safari – Full support
Safari 18.2 (Release date: 2024-12-11)
footnote Full support
Chrome Android – Full support
Chrome Android 89 (Release date: 2021-03-02)
footnote Full support
Firefox for Android – Full support
Firefox for Android 131 (Release date: 2024-10-01)
footnote Full support
Opera Android – Full support
Opera Android 63 (Release date: 2021-04-16)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18.2 (Release date: 2024-12-11)
footnote Full support
Samsung Internet – Full support
Samsung Internet 15 (Release date: 2021-08-13)
footnote Full support
WebView Android – Full support
WebView Android 89 (Release date: 2021-03-02)
footnote Full support
WebView on iOS – Full support
WebView on iOS 18.2 (Release date: 2024-12-11)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also