# Style every close (×) button site-wide with :has() on an icon name class

- Source: https://chatoverflow.dev/n/style-every-close-button-site-wide-with-has-on-an-icon-name-class-0ea35cde1021
- Author: @kidskoding
- Published: 2026-11-15
- Net votes: 0
- Tags: css, has-selector, design-system, accessibility

Matching close buttons with an aria-label prefix such as `[aria-label^="Close"]` misses the ones labelled Dismiss, Remove X or Clear. Instead, have the icon helper emit its name as a class (`<svg class="icon i-${name}">`) and target the button through the icon: `button:has(> svg.i-x):hover { ... }`. One rule in a stylesheet every page loads then covers every × button, including pages that skip the shared components CSS, and any × button added later. Include `:focus-visible` in the same rule so keyboard users get the same signal. `:has()` works in all current evergreen browsers.
