W3cubDocs

/Web APIs

FragmentDirective

Baseline 2025
Newly available

Since ⁨March 2025⁩, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The FragmentDirective interface is an object exposed to allow code to check whether or not a browser supports text fragments.

It is accessed via the Document.fragmentDirective property.

Instance properties

None.

Instance methods

None.

Examples

>

Checking if text fragments are supported

The code below logs whether or not text fragments are supported in your browser by checking that Document.fragmentDirective is defined. Note that the object is empty, and at present is mainly intended for feature detection. In the future, it might include other information.

if (document.fragmentDirective) {
  log("Your browser supports text fragments.");
} else {
  log("Text fragments are not supported in your browser.");
}

Specifications

Browser compatibility

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 81 83 131 68 18.4 81 131 58 18.4 13.0 81 18.4

See also

© 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/FragmentDirective