Skip to content

[css-lists-3] Inconsist counter() syntax between CSS 2 and 3 #5795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
xiaochengh opened this issue Dec 15, 2020 · 6 comments
Open

[css-lists-3] Inconsist counter() syntax between CSS 2 and 3 #5795

xiaochengh opened this issue Dec 15, 2020 · 6 comments

Comments

@xiaochengh
Copy link
Contributor

Should content: counter(c, none) be a parse-time failure, or a valid value that generates empty text?

In CSS 2.1:

  • counter() = counter(name, <list-style-type>?) [1], where
  • <list-style-type> = disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit [2]

So content: counter(c, none) is a valid declaration that doesn't generate any text. Chrome implements this behavior.

In CSS 3:

  • counter() = counter( <counter-name>, <counter-style>? ) [3], where
  • <counter-style> = <counter-style-name> | <symbols()> [4], where
  • <counter-style-name> is a <custom-ident> that is not an ASCII case-insensitive match for "none". [5]

So content: counter(c, none) is invalid at parse time. Firefox implements this behavior.

My proposal: We should not allow none. Allowing none in CSS 2.1 looks like a spec bug to me, since it provides little value and doesn't make too much sense. (And the same syntax also allows inherit, which makes no sense at all).

[1] https://www.w3.org/TR/CSS2/generate.html#counter-styles
[2] https://www.w3.org/TR/CSS2/generate.html#propdef-list-style-type
[3] https://drafts.csswg.org/css-lists-3/#counter-functions
[4] https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style
[5] https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style-name

@fantasai fantasai added the css-lists-3 Current Work label Dec 15, 2020
@SebastianZ
Copy link
Contributor

It was already agreed on to make none an invalid value in #4163.

As the definition in CSS Lists 3 supercedes the one in CSS 2 (and CSS 2.2) and already excludes none as well as all CSS-wide keywords, I think nothing needs to be done here.

If something needs to be corrected, it is CSS 2.2 that still says that counter(x, none) yields an empty string instead of making it invalid.

Sebastian

@Loirooriol
Copy link
Contributor

Loirooriol commented Dec 16, 2020

So what's strange here is that #4163 claimed that a none counter style was invalid in CSS2, and wanted to align css-lists-3 with that. But actually none was valid in CSS2 according to https://www.w3.org/TR/CSS2/syndata.html#counter and https://www.w3.org/TR/CSS2/generate.html#counter-styles ?

@fantasai
Copy link
Collaborator

@Loirooriol https://www.w3.org/TR/CSS2/generate.html#content

<counter>
Counters may be specified with two different functions: 'counter()' or 'counters()'. [...] The name must not be 'none', 'inherit' or 'initial'. Such a name causes the declaration to be ignored.

Generally-speaking, prose restrictions override grammar leniency.

Agree with @SebastianZ that the example in syndata.html needs to be fixed, though. :/ That's definitely self-inconsistent.

@Loirooriol
Copy link
Contributor

@fantasai Precisely, it says "The name must not be 'none'", given counter(name, style). Here we are talking about the style, not the name.

@Loirooriol
Copy link
Contributor

Also note https://www.w3.org/TR/CSS2/generate.html#counter-styles says

All the styles are allowed, including 'disc', 'circle', 'square', and 'none'.

P:before         { content: counter(p, none) }

@SebastianZ
Copy link
Contributor

@Loirooriol is right. The initial claim in #4163 that counter(name, none) and counters(name, "string", none) are invalid was wrong.

Though I agree with @xiaochengh that neither <counter-name> nor <counter-style-name> should allow none, i.e. align CSS 2.2 with CSS Counter Styles 3 for the same reasons as @fantasai outlined in #4163.

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants