Re: [csswg-drafts] [css-page] Spec seems confused about descriptors and properties (#5969)

We're obviously diving deep into the Syntax spec. here and are side-tracking with `@nest`. But here's how I interpret this.

> There is also this part in [CSS Syntax 3 - 9.2. At-rules](https://drafts.csswg.org/css-syntax-3/#at-rules):
> 
> > At-rules are used to: [...] declare style information that is not associated with a particular element, such as defining counter styles [...]
> > Block at-rules will typically contain a collection of (generic or at-rule–specific) at-rules, qualified rules, and/or descriptor declarations subject to limitations defined by the at-rule.
> 
> If I'm not mistaken, `@nest` contains property declarations.

Yes. I guess `@nest` is a special case as it's something between a typical at-rule and a style rule. I looks to me that it is not covered by the list under 9.2. yet. Therefore, the following point in the list should probably be extended to include [`<style-block>`](https://drafts.csswg.org/css-syntax-3/#typedef-style-block) declarations:

> group and structure style rules and other at-rules such as in [conditional group rules](https://drafts.csswg.org/css-conditional-3/#conditional-group-rule)

Though that's something that should be discussed in a separate issue.

> In my personal experience, the distinction made in the definition of a [declaration](https://drafts.csswg.org/css-syntax-3/#declaration) (quoted below) between property and descriptor declarations was not enough. Sometimes I still (incorrectly) associate at-rules to descriptor declarations and qualified rules to property declarations.

The association should be the other way round. Descriptor declarations are _always_ part of an at-rule. Though property declarations are normally part of a qualified rule but _can also_ be part of an at-rule.

> > Declarations are further categorized as **property declarations** or **descriptor declarations**, with the former setting CSS properties and appearing most often in qualified rules and the latter setting CSS descriptors, which appear only in at-rules. (This categorization does not occur at the Syntax level; instead, it is a product of where the declaration appears, and is defined by the respective specifications defining the given rule.)
> 
> CSS Nesting does not seem to clearly define that nested style rules (directly nested or `@nest`) contain property declarations.

In my opinion, it has a clear definition in its syntax and in textual form. It [says this](https://drafts.csswg.org/css-nesting-1/#at-nest):

> The [`@nest`](https://drafts.csswg.org/css-nesting-1/#at-ruledef-nest) rule functions identically to a [nested style rule](https://drafts.csswg.org/css-nesting-1/#nested-style-rule): it starts with a selector, and contains a block of declarations that apply to the elements the selector matches. That block is treated identically to a [style rule’s](https://drafts.csswg.org/css-syntax-3/#style-rule) block, so anything valid in a style rule (such as additional `@nest` rules) is also valid here.

And the [syntax definition](https://drafts.csswg.org/css-nesting-1/#at-ruledef-nest) looks like this:

```
@nest = @nest <selector-list> { <style-block> }
```

So it clearly states that everything in it is a [style block](https://drafts.csswg.org/css-syntax-3/#typedef-style-block), which represents the contents of a style rule's block.

> > Descriptors are similar to properties (and are declared with the same syntax) but are associated with a particular type of at-rule rather than with elements and boxes in the tree.
> 
> If I set out to distinguish a property/descriptor based on whether it applies to an element or an at-rule, I'm in trouble.

What exactly is your issue here?

Coming back to `@page`, there's an important point in a side note that makes it obvious that the declarations in it do _not_ apply to elements (emphasizing by me):

> An [`@page`](https://drafts.csswg.org/css-page-3/#at-ruledef-page) rule consists of the keyword `@page`, an optional comma-separated list of [page selectors](https://drafts.csswg.org/css-page-3/#page-selector) and a block of declarations (**_said to be in the page context_**).

So the declarations only apply to a page and not to elements, so they are descriptors.

> Furthermore, afaict, a declaration in a feature/supports or style query (`<supports-decl>` or `<style-feature>`) contained in the prelude of `@supports` or `@container`, can only be a property declaration.

I'd say so, but again, style declarations are not prohibited within at-rules.

> Maybe a note below the definition of a declaration, with some examples can be helpful for people like me who are not able to figure out quickly and persistently remember how to tell them apart.

👍🏻 from me for that.

For reference I want to note #632 and the [related commit](https://github.com/w3c/csswg-drafts/commit/30e1273058b3315ed4dfb2f74e26bf27e4eed0c2), in which the syntax of `@page` got clarified. See its current [grammar definition](https://drafts.csswg.org/css-page-3/#syntax-page-selector).

Sebastian

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


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

Received on Sunday, 14 August 2022 19:51:05 UTC