:has()

Use With Caution Updated: Dec 17, 2025

Selector for selecting the parent or previous element based on detecting the presence of child elements or sibling relationships.

Baseline:
Newly
Functional:
Progressing
Usage:
Cross-Context

The :has() selector has mixed browser support for shadow DOM usage, with missing consensus on expected behavior. Cross-browser, :has() cannot cross the light/shadow boundary to peer into a different scope. Host-based selectors like :host:has() and :host(:has()) have inconsistent support across browsers. Only :host:has() is presently accepted in the spec.

Ranked caution due to mixed browser consensus — effective use is limited to elements within the same scope, without relying on host-based or cross-boundary selectors.

Shadow DOM Related Issues

Should :host:has() match

Resolved that :host:has() should be allowed to match, but browser support is inconsistent.

Stable

Should :host(:has()) match

Discussion is still occurring, given Safari and Firefox are presently able to support at least a simple selector.

May Change
Web Platform Test
Chrome 147
Edge 146
Firefox 149
Safari 26.4
host-has-internal-001
pass
pass
fail
fail
host-has-internal-002
pass
pass
fail
fail
host-has-internal-003
pass
pass
fail
fail
host-has-internal-004
pass
pass
fail
fail
slotted-has-001
fail
fail
pass
pass
slotted-has-002
fail
fail
pass
pass
slotted-has-003
fail
fail
pass
pass
slotted-has-004
fail
fail
pass
pass
WPT sources: host-has-internal-001, host-has-internal-002, host-has-internal-003, host-has-internal-004, slotted-has-001, slotted-has-002, slotted-has-003, slotted-has-004