scope property

Image Tutorials

Definition and Usage

The :scope CSS pseudo-class matches the elements that are a reference point for selectors to match against. In HTML, a new reference point can be defined using the scoped attribute of the <style>. If no such attribute is used on an HTML page, the reference point is the <html> element, making :scope equivalent to :scope


Syntax

:scope { style properties }

Examples

01 <article>
02   The element selected by :scope has a lime background if your browser supports scoped stylesheet.
03   <section>
04     <p>Outside scope.</p>
05   </section>
06   <section>
07     <style scoped>
08       :scope { background-color: lime; }
09     </style>
10     <p>Inside scope.</p>
11   </section>
12 <section>
13     <p>Outside scope.</p>
14   </section
15 </article>

Compatibility

Desktop browsers

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support NA Not supported Not supported Not supported Not supported

Mobile browsers

Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support NA Not supported Not supported Not supported Not supported

Rate article