Skip to main content

What does the :has() selector do?

The :has() selector in CSS selects an element if it contains, among its descendants or siblings, the specified element. It is a "has" selector. For example, you can style a card only if it contains an image.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.