CSS :focus-within Playground

The Balai’s porch light is on while focus is inside the sign-in card: the browser answers which ancestors match :focus-within, what your CSS changed, and…

Why it matters

A form card that lights up, the active row, a clear button that shows while typing, a dropdown that stays open while focus is inside: all pure CSS. No listener to forget to clean up, and no flicker as focus moves between fields.

The key idea

focus-within means me or one of my descendants has focus

Common mistakes

Try it in this playground