← Back

:has() - CSS Parent Selector

Ever wanted to be able to style a parent depending on the content that it contains? The `:has()` selector allows you to do this

div {
border: 1px solid black;
}

div:has(button) {
border-color: red;
}

Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nesciunt architecto soluta asperiores harum illum labore, necessitatibus reiciendis quasi laudantium doloribus excepturi illo temporibus ab. Eligendi sequi quas eum ipsam aperiam.

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Totam adipisci tempore quibusdam dignissimos fuga, animi nam ab, earum tempora commodi ratione. Tenetur nisi voluptates eius debitis accusantium, itaque cum. Rem.