:has()
Widely availableSince 202396% of users
Matches an element if it contains at least one descendant or preceding element that matches the selector provided in the arguments. It is often referred to as the 'parent selector'.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since December 2023. Widely available since June 2026.
See how modern your own CSS is.Check your CSS →
Quick example
/* Style a card only if it contains an image */
.card:has(img) {
padding: 0;
border: 2px solid var(--accent);
}Related snippet
Selecting parent elements without JavaScriptSelectors →:has() browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2023.Safe to use without fallbacks.
Usage96%of people can use this4% use a browser without it.
Browsers
105+
121+
15.4+
105+Mobile
105+Android
121+Android
15.4+iOS