MDN self-hosted library · e01.org

`:local-link` CSS pseudo-class

The :local-link CSS pseudo-class represents a link to the same document. Therefore an element that is the source anchor of a hyperlink whose target's absolute URL matches the element's own document URL.

The :local-link CSS pseudo-class represents a link to the same document. Therefore an element that is the source anchor of a hyperlink whose target's absolute URL matches the element's own document URL.

/* Selects any <a> that links to the current document */
a:local-link {
  color: green;
}

Syntax

:local-link {
  /* ... */
}

Examples

HTML

<a href="#target">This is a link on the current page.</a><br />
<a href="https://example.com">This is an external link</a><br />

CSS

a:local-link {
  color: green;
}

Result

Examples

Specifications

Browser compatibility

Currently, no browsers support this feature.

See also

  • Link-related pseudo-classes: :link, :visited, :hover, :active, :any-link
  • CSS selectors module