The :scope
CSS pseudo-class represents elements that are a reference point for selectors to match against.
/* Selects a scoped element */ :scope { background-color: lime; }
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.