CSS Parent Selector :has

The :has pseudo-class is a powerful and versatile selector that allows you to apply styles based on the presence of child elements or specific conditions within a parent element. It's often referred to as a "parent selector," as it enables styling of an element depending on its descendants, something previously challenging to achieve with pure CSS.

form:has(input:invalid) {
  background-color: #ffe6e6;
}  
html:has(dialog[open]) {
  overflow: hidden;
}  

More info on MDN.