CSS :scope Selector

❮ Previous Selectors Next ❯

Example

/* Selects a scoped element */
:scope {
  background-color: red;
}

Meaning

The :scope selector represents elements that are a reference point for selectors to match against.

Currently, when used in a stylesheet, :scope is the same as :root, since there is not at this time a way to explicitly establish a scoped element.

When used from a DOM API such as querySelector(), querySelectorAll(), matches(), or Element.closest(), :scope matches the element on which the method was called.

Version: CSS3




Standard Syntax

:scope {
  css declarations;
}



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







❮ Previous Selectors Next ❯