MDN self-hosted library · e01.org
Text fragments / notebook

Text fragments

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<h2 id="browser_compatibility">
  <a href="#browser_compatibility">Browser compatibility</a>
</h2>
css
::target-text {
  background-color: rebeccapurple;
  color: white;
}
js
document.fragmentDirective;
// returns an empty FragmentDirective object, if supported
// undefined otherwise