w3c / w3c/csswg-drafts

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

Open
#10,491 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-lists-3
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

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? https://github.com/w3c/csswg-drafts/issues/5477#issuecomment-1843956580

(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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CSS Lists § Nested Counters and Scope and Example 22, then read the linked 2020 counter-inheritance change and CSSWG issue 5477. Compare the prose and example with the behavior reported for Chromium 126. Done means the affected description and example accurately reflect the resolved counter behavior, including any needed compatibility note.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.