:has-slotted

Matches a 'slot' in the Shadow DOM if it contains content that matches the selector. It's used within Web Components to style slots based on what's been put inside them.

/* Usage Example */
/* Styles the slot if it has an image inside it */
::slotted(div):has-slotted(img) {
  border: 4px solid blue;
}
Limited availability Since 2020 2% global usage

This feature is not Baseline because it does not work in some of the most widely-used browsers.

136+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC