@scope

noun

say it: “AT skohp” /æt skoʊp/

A CSS at-rule that limits the rules inside it to one part of the page, with an optional inner edge where they stop applying.

What does @scope do?

@scope limits rules to a part of the page, optionally stopping at an inner boundary.

@scope (.article) to (.comments) {
  a { color: navy; }   /* article links, not links in the comments */
}

In a sentence

  • “I wrapped the card rules in @scope (.product-card) so plain img and h3 selectors only reach inside the card.”
  • “With @scope (.article) to (.comments), the article's link color stops where the comments begin.”

Level: Freelancer · More CSS terms at this level

Updated