The
:focus-within
CSS pseudo-class matches an element if the element or any of its descendants are focused. In other words, it represents an element that is itself matched by the:focus
pseudo-class or has a descendant that is matched by:focus
. (This includes descendants in shadow trees.)
Since CSS has difficulty targeting a 'parent element', this can be a useful tool for styling the parent of a focusable element.