x = .nesting {
color: hotpink;
}
y = x > .is {
color: rebeccapurple;
}
y > .awesome {
color: deeppink;
}
plus:
x = .nesting;
y = x > .is;
z = y > .awesome;
x {
color: hotpink;
}
y {
color: rebeccapurple;
}
z {
color: deeppink;
}
The names x, y and z aren't ambiguous because they are lexically defined. They could be allowed to shadow tags:
pre = .foo > .bar;
then from that point on, pre isn't the HTML tag, but the above definition. Or else tags could be reserved: cannot use those as names. (Causing trouble when new tags get introduced; bad idea.)
Regarding the @nest syntax, why couldn't it look like an attribute?
Why use containment to express the nesting? What is being nested is the selectors. The braces group something else: the attributes affected by selectors. Why would nested selectors have to go into those braces?
The + character at the start of a rule could mean "the selector of the previous rule":
Here, because the nested @stack follows a block of parallel rules, a Cartesian product semantics can come into effect. That is to say, it is equivalent to:
The mandatory : could be followed by required whitespace, making :: a syntax error.
Or the whitespace could be strongly recommended, with implementations encouraged to diagnose if it is missing, at least in ambiguous-looking situations like ::hover. (Is that a forgotten space? Or a forgotten colon?)
(or if it (1) means (2) then it is unable to represent the A below)
In other words you can write
<div>Hi<span>there</span></div>
And using the first one get a red there on hover (A). But the second one intends to get a purple Hi there on hover (B). But You can't express that because the mandatory space clashes with the CSS (implicit) descendent combinator (space).
Regarding the @nest syntax, why couldn't it look like an attribute?
Or just the colon: Why use containment to express the nesting? What is being nested is the selectors. The braces group something else: the attributes affected by selectors. Why would nested selectors have to go into those braces?The + character at the start of a rule could mean "the selector of the previous rule":
Or use a master outer brace for this: The understanding is that the rules grouped in the brace have a cumulative selector, rather than independent selectors.Or what if braces just group, and @nest (or whatever) is required to indicate the selector stacking semantics:
Now you can have N levels of selector refinement without N levels of syntactic containment. The containment is still available: Here, because the nested @stack follows a block of parallel rules, a Cartesian product semantics can come into effect. That is to say, it is equivalent to: The @stack following a parallel rule causes the @stack to distribute into the parallel branches.Kind of like Bash brace expansion: