Skip to content

[css-cascade-6] add a :stylesheet selector to match the current stylesheet #7349

@faceless2

Description

@faceless2

This is derived from both #3547 and (in particular) #6606, but I've opened a new issue as it's a more specific proposal.

Suggestion is: add a :stylesheet pseudo-class selector which functions like :scope but matches the element that declared the rule - ie the <style> or <link>element that created the stylesheet. For programatically created stylesheets, it would match nothing.

  • I suspect this would be very easy to implement as the rule should already have a reference to the stylesheet that declared it.
  • it would mean the functionality of the old <style scoped> syntax could be reproduced. This has been pretty heavily discussed in 3547, it was clearly popular, and while @scope is good it doesn't(*) provide a direct replacement for that functionality. :stylesheet would do that:
<style>
@scope (* > :stylesheet) {
...
}
</style>

(* you could give the <style> an id and reference that from the @scope rule, so it's technically possible; just not very flexible)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions