:has()
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'.
Quick example
/* Style a card only if it contains an image */
.card:has(img) {
padding: 0;
border: 2px solid var(--accent);
}:has() Browser Support
Widely availableSince 202394% global usage
This 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.
105+
121+
15.4+
105+