Archive for the ‘:focus-within’ Category

Keeping Parent Visible While Child in :focus

Posted on: No Comments
Say we have a <div>. We only want this div to be visible when it's hovered, so: div:hover { opacity: 1; } We need focus styles as well, for accessibility, so: div:hover, div:focus { opacity: 1; } But div's can't be focused on their own, ...

The `:focus-within` Pseudo Class

Nice find by Ian Devlin: The :focus-within pseudo class becomes active when an element itself has focus or if any of its descendants does. Selecting a parent element based on children is lonnng awaited. The crown jewel of that is :has(). I wonder if th...