Web platform features explorer

:target-within

This feature is discouraged — The :target-within pseudo-class was dropped from the specification in favor of :has(:target).

Consider using :has() , :target instead.

For more information, see: selectors-4/#the-target-pseudo (CSSWG draft) , w3c/csswg-drafts/issues/8357 (GitHub)

The :target-within CSS pseudo-class matches the element with an ID matching the URL fragment and its ancestors.

Status

Discouraged

Browser support

  • Chrome
  • Chrome Android
  • Edge
  • Firefox
  • Firefox for Android
  • Safari
  • Safari on iOS