# :has()

Styles an element based on what it contains.

## What does `:has()` do?

`:has()` styles an element based on what is inside it, like "a card that contains an image". It is often called the parent selector.

```css
.card:has(img) { padding-top: 0; }
form:has(:invalid) .submit { opacity: 0.5; }
```

Level: Freelancer · [More CSS terms at this level](https://www.ask-codey.com/glossary/subjects/css/freelancer)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/has
