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

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
fragmentDirective

Legend

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

Full support
Full support
No support
No support
See implementation notes.

api.FragmentDirective

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
FragmentDirective

Legend

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

Full support
Full support
No support
No support
See implementation notes.

css.selectors.target-text

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
::target-text

Legend

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

Full support
Full support

See also