Quick Win

Style one element based on another

Use the :has() pseudo-class to select a parent based on its child.

Est. 1 min readIntermediate

Published

Use the :has() pseudo-class to select a parent based on its child.

.card:has(img) {
  border: 2px solid var(--accent);
}

:has() enables powerful parent-child styling in native CSS.

layout · intermediate