The CSS `:has()` pseudo-class lets you style a parent element based on its children. A practical example shows how to highlight form fields in red when they contain an input with `aria-invalid="true"`, using a CSS custom property to cascade the color change. Browser support at time of writing was limited to Chrome/Edge 105+ and Safari 15.4+.

1m read timeFrom matuzo.at
Post cover image