Re: [csswg-drafts] [css-nesting] Syntax suggestion (#4748)

"parameters that govern when the at-rule takes effect" certainly describes the relationship between a selector and the declarations inside of it, yeah.

> Don't all the at-rules then go on to wrap the CSS they're "governing" (or the from..to in @keyframe's case) in enclosing brackets?

Yes, but not as an intrinsic quality. 

@media/@supports wraps style rules because the style rules are separate from the media/support query. In theory we could have instead had @media take a MQ then immediatley a selector, and then have its body just contain declarations, but that would be exceedingly cumbersome for authors because you almost always are using one MQ to set a large number of styles on different elements, and this syntax would require you to repeat *the whole MQ* on each one.

@keyframes wraps its keyframe rules because (a), again, the standard is to have a reasonably large number of keyframes, and repeating `@keyframes <name>` on each would be rather cumbersome, and (b) because keyframes have "last wins" behavior if multiple are defined with the same name, and that's fairly desirable (otherwise, we'd have to, I guess, merge the frames from each?). Having a bunch of separately-tagged frames wouldn't allow this.

> However, I don't think there are any at-rules that are currently valid as a "sibling" of a selector's properties, so.... shrug

Yes, no at-rules are *currently* valid inside of a style rule. But that's, again, not an intrinsic restriction; we just haven't defined any yet to do so, since existing at-rules aren't element-specific. There are already some that *absolutely* make sense inside of a style rule, such as @media/@supports, and preprocessors allow this; in CSS we were just waiting for the Nesting functionality to exist before we allowed it (and the Nesting spec, thus, defines them as valid there).

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4748#issuecomment-966679286 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 11 November 2021 22:47:05 UTC