@scope <where the elements matched by the <> { < > }
This rule makes it very easy for authors to create scoped style sheets,
which could affect the optimization strategies for implementing scoped styles.
If multiple elements match the <
@scope div {
span {
color: blue;
}
}
@scope section {
span {
color: orange;
}
}
and the following document fragment
<div>
<section>
<div>
<span>text</span>
</div>
</section>
</div>
the text will be blue.
@scope aside {
p { color: green; }
}
aside#sidebar p { color: red; }
Querying the Scoping Context
Selecting the Scoping Root: '':scope'' pseudo-class
In a scoped stylesheet,
the '':scope'' pseudo-class,
defined in [[SELECTORS4]],
matches the scoping root.
Selecting Outside the Scope: '':scope-context()'' pseudo-class
:scope-context(<
This functionality would replace ''@global'', which is a poor excuse for a selector.
Fragmented Styling
Fragmented content can be styled differently
based on which line, column, page, region, etc.
it appears in.
This is done by using an appropriate fragment pseudo-element,
which allows targetting individual fragments of an element
rather than the entire element.
#region1::region p {
color: #0C3D5F;
font-weight: bold;
}
The ''::region'' pseudo-element
is followed by a ''p'' relative selector in this example.
The color and font-weight declarations will apply
to any fragments of paragraphs that are
displayed in ''#region1''.
The following figure shows how
the rendering changes
if we apply this styling specific to ''#region1''.
Note how less text fits into this box
now that the 'font-weight!!property' is
bold instead of normal.
Region-based Styling: the ''::region'' pseudo-element
<region selector>::region <content selector> {
... CSS styling declarations ...
}
When the ::region pseudo-element is appended to a
selector
that matches one or more CSS Regions,
this creates a 'flow fragment' selector.
The flow fragment selector specifies
which range of elements in the flow
can be matched by the relative selector.
The relative selector can match elements
in the range(s) (see [[!DOM]]) of the named flow
that are displayed fully or partially
in the selected region(s).
Elements that are fully or partially
in the flow fragment range may match the relative selector.
However, the style declarations only apply
to the fragment of the element
that is displayed in the corresponding region(s).
Only a limited list of properties apply to a ::region pseudo-element:
Issue: Either this list should be all functionally inheritable properties,
or all properties.
Why is it a seemingly-arbitrary subset of all properties, including box properties?
1. font properties
2. color property
3. opacity property
4. background property
5. 'word-spacing'
6. 'letter-spacing'
7. 'text-decoration'
8. 'text-transform'
9. 'line-height'
10. alignment and justification properties
11. border properties
12. rounded corner properties
13. border images properties
14. margin properties
15. padding properties
16. 'text-shadow'
17. 'box-shadow'
18. 'box-decoration-break'
19. 'width'
<style>
#div-1 {
flow-into: article-flow;
}
#region-1, #region-2 {
flow-from: article-flow;
}
/* region styling */
#region-1::region p {
margin-right: 5em;
}
</style>
<body>
<div id="div-1">
<p id="p-1">...</p>
<p id="p-2">...</p>
</div>
<div id="region-1"></div>
<div id="region-2"></div>
</body>
getComputedStyle() isn't enough,
because an element can exist in multiple regions, for example,
with each fragment receiving different styles.