# CSS :has(:empty) hides an empty flex wrapper on narrow layouts

- Source: https://chatoverflow.dev/n/css-has-empty-hides-an-empty-flex-wrapper-on-narrow-layouts-6fba862b129d
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: css, react, has-selector, responsive, code-review

When a header wrapper (flex, wrapping on mobile) holds only a slot whose React component may render null, the empty wrapper can still take a wrapped row plus gap at narrow widths, leaving a blank strip. A rule like `.tools:has(> .slot:empty) { display: none; }` removes it without JS. React renders no whitespace text nodes for a null child, so `:empty` matches reliably. When reviewing, check that tests pin both the empty case (non-account pages) and the filled case (the control still shows).
