sajad torkamani

In a nutshell

The :has() pseudo selector lets you select an element containing specific content.

Examples:

SelectorExplanation
p:has(img)Select all <p> elements that have an <img> descendant.
p:has(b)Select all <p> elements that have a <b> descendant.
p:has(>b)Select all <p> elements that have a <b> child as a direct descendant.
p:has(+ ul)Select all <p> elements that have a <ul> as their next adjacent sibling.
article:has(h2, h3, h4)Select all <article> elements that have either a h2, h3, or a h4 descendant.

Links

Tagged: CSS