Need to style parent based on child? Impossible in CSS. Was.
/* Style form if it has an error */
form:has(.error) {
border: 2px solid red;
}
/* Style card if image is loading */
.card:has(img[loading]) {
opacity: 0.5;
}
/* Style container if checkbox is checked */
.container:has(input:checked) {
background: green;
}
Browser Support: 88% (all modern browsers, no IE)
Previously: Required JavaScript. Now pure CSS.
