Limited support Limited browser support. Check compatibility before use.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
136
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

CSS
slot:has-slotted {
  border: 1px solid blue;
  padding: 8px;
}
slot:not(:has-slotted) {
  color: gray;
}

Live demo

slot with

CSS slot with demo.

PreviewFullscreen

slotempty

CSS slotempty demo.

PreviewFullscreen

condition withstyle

CSS condition withstyle demo.

PreviewFullscreen

Use cases

  • Using :has-slotted

    The :has-slotted CSS pseudo-class matches when the content of a <slot> element is not empty or not using the default value (see Using templates and slots for more information).

Cautions

  • Limited browser support. Check compatibility before use.

Accessibility

  • Make sure visual changes are conveyed appropriately to assistive technology.