Welcome
TIL: CSS :has() selector.md
All Notes
notes/til:-css-:has()-selector

TIL: CSS :has() selector

| notes

The :has() selector is finally here.

/* Style parent based on child */
.card:has(img) {
  padding: 0;
}

/* Style sibling based on another */
h2:has(+ p) {
  margin-bottom: 0.5rem;
}

Parent selector in CSS is now possible.