Skip to content

[css-lists] CSS counter scope description, example no longer accurate #10491

@stefanbrand-rldatix

Description

@stefanbrand-rldatix

There are a couple places where I think the spec could be updated to be more clear for some of the more recent changes around counter inheritance and the precedence of counters from the parent vs. the previous sibling.

*Maybe these changes won't be necessary as the changes to the spec might be getting reverted? #5477 (comment)

(Recent versions of chromium just started adopting these changes, the latest stable chrome 126 has them implemented, which is how I noticed)

Example 22

https://drafts.csswg.org/css-lists/#example-b1a4542d

Example 22 in the spec doesn't fully match the behavior as described in the spec anymore

Specifically, the latest change to counter inheritance causes the last h2 in the example to inherit the h2 counter value that is copied from the body parent instead of the previous h1 sibling's nested h2 counter. So instead of rendering 'B.1 First H2 in H1' it now renders 'B.3 First H2 in H1'.

The latest versions of chromium, starting in 126, started following this change in the spec.

Maybe just need to change the example to use counter-set instead of counter-reset for the h1, h2, and h3 rules? Might be helpful to add some sort of note since this broke backwards compatibility to the current example.

Nested Counters and Scope

https://drafts.csswg.org/css-lists/#nested-counters

I think the description of the scope of a counter could be updated as well, as it seems that the scope doesn't extend to the element's following siblings in the case when there is a counter on the parent element of the same name.

The scope of a counter therefore starts at the first element in the document that instantiates that counter and includes the element’s descendants and its following siblings with their descendants. However, it does not include any elements in the scope of a counter with the same name created by a counter-reset on a later sibling of the element, allowing such explicit counter instantiations to obscure those earlier siblings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions