ThatDev.Shparki

Today I Learned

TIL: CSS :has() selector

css til

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.