CSS :has()
The "parent selector" — select an element based on what it contains. article:has(img) matches articles that contain an image.
Stable in all modern browsers since 2023 (Chrome 105, Safari 15.4, Firefox 121). Works with any selector inside: li:has(> a.active), form:has(input:invalid), :has(+ p). Eliminates piles of JavaScript hacks and makes form styling realistic without class manipulation.
Performance is surprisingly good — browsers do smart invalidation. The only real downside is that you have to stop thinking in the "the parent doesn't know about the child" paradigm.