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.
FragmentDirectiveA (currently) empty object. The existence of an object of this type in document.fragmentDirective is used for feature detection.
Document.fragmentDirectiveA property that returns a FragmentDirective object for the current document. Currently only used for feature detection.
::target-textRepresents the text that has been scrolled to. It allows authors to choose how to highlight that section of text.
| Specification |
|---|
| URL Fragment Text Directives> # dom-document-fragmentdirective> |
| URL Fragment Text Directives> # fragmentdirective> |
| CSS Pseudo-Elements Module Level 4> # selectordef-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 | |
URL_Fragment_Text_Directives |
86 | 86 | 131 | 72 | 18.4 | 86 | 131 | 61 | 18.4 | 14.0 | 86 | 18.4 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
URL_Fragment_Text_Directives |
81 | 83 | 131 | 68 | 18.4 | 81 | 131 | 58 | 18.4 | 13.0 | 81 | 18.4 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
URL_Fragment_Text_Directives |
89 | 89 | 131 | 75 | 18.2 | 89 | 131 | 63 | 18.2 | 15.0 | 89 | 18.2 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/URL_Fragment_Text_Directives