Also called: parent selector
Example
With :has(), cards that contain an image get a different layout automatically.
In code
.card:has(img) { padding-top: 0; }
form:has(:invalid) button[type="submit"] { opacity: .5; }
Learn more
Related terms
Added 2026-11-30 · Last reviewed 2026-11-30