Skip to content
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

Issue with "counter-reset": the example is a bit confusing #2793

Open
MatsPalmgren opened this issue Jun 23, 2021 · 7 comments
Open

Issue with "counter-reset": the example is a bit confusing #2793

MatsPalmgren opened this issue Jun 23, 2021 · 7 comments
Labels
Content:CSS issues related to CSS examples. effort: medium Task is a medium effort. idle Issues and pull requests with no activity for three months.

Comments

@MatsPalmgren
Copy link
Contributor

MDN URL: https://developer.mozilla.org/en-US/docs/Web/CSS/counter-reset

What information was incorrect, unhelpful, or incomplete?

The example at the start of the article is a bit confusing.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1717772 for details why.
The example kind of misleading since it's not how you would typically use nested counter scopes.
(I guess it was written before we changed CSS counters to be compatible with HTML list ordinals, which are now defined in terms of the built-in CSS list-item counter.)

Specific section or headline?

What did you expect to see?

Did you test this? If so, how?

MDN Content page report details
@sideshowbarker sideshowbarker added the Content:CSS issues related to CSS examples. label Jun 24, 2021
@rachelandrew rachelandrew self-assigned this Jun 24, 2021
@rachelandrew rachelandrew added the effort: medium Task is a medium effort. label Jun 24, 2021
@rachelandrew
Copy link
Collaborator

Thanks for raising this, and for the test cases. I've updated the example to use counters(). Once that shows up on the page I'll go add some text to explain what is happening there.

@MatsPalmgren
Copy link
Contributor Author

I think the main issue with the example is that it's poorly marked up. One should never have first and second level headings be siblings in a flat list like this. I'm aware that it's just a brief example just to show the effect of a few counter-reset values, but people take these examples and use them as templates for their documents. So it would be great if we could flesh out the example with markup as recommended by the HTML spec. I believe that would look something like this:

<style>
#default-example {
    counter-reset: chapter-count;
}
h2, h3 {
    counter-increment: chapter-count;
}
h2::before, h3::before {
    content: "Chapter " counters(chapter-count, ".") ": ";
}
</style>

<section id="default-example" class="default-example">
  <h1>Alice's Adventures in Wonderland</h1>
  <section>
    <h2>Down the Rabbit-Hole</h2>
    <p>Alice was beginning to get very tired ...</p>
    <section>
      <h3 id="example-element">The Pool of Tears</h3>
      <p>`Curiouser and curiouser!' cried Alice ...</p>
    </section>
  </section>
  <section>
    <h2>A Caucus-Race and a Long Tale</h2>
    <p>They were indeed a queer-looking party ...</p>
  </section>
  <section>
    <h2>The Rabbit Sends in a Little Bill</h2>
    <p>It was the White Rabbit ...</p>
  </section>
</section>

In particular, each level should be wrapped in nested sectioning elements (<section> here).
Then the example renders as intended also in Chrome.

@Rumyra Rumyra added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 25, 2021
@hamishwillee
Copy link
Contributor

Hi @MatsPalmgren

Before looking at this example that I am looking at the compatibility information here: mdn/browser-compat-data#15666. Can you please confirm my assumptions?

Essentially those assumptions are:

  • siblings in a nesting level are assigned a new counter. My assumption is that it is just one counter they all share initially.
  • calling counter-reset on an element creates a new counter and assigns it to just that element. Siblings before and after keep the original (shared) counter.
  • calling counter-set on an element resets the value of the shared counter assigned to that element.
  • The original example was a bit odd because it reset just one sibling half way through the list so previous and subsequent numbering was unaffected. The likely intent was that the number changed after calling counter-reset and continued. To do that you would call counter-set

About right?

@sideshowbarker sideshowbarker added needs info This needs more information to review or act on. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Apr 8, 2022
@sideshowbarker
Copy link
Collaborator

@MatsPalmgren This is waiting on your response to #2793

@sideshowbarker
Copy link
Collaborator

@hamishwillee Given the lack of response, how should we proceed with this?

@hamishwillee
Copy link
Contributor

@sideshowbarker IMO this is a valid unassigned issue - so we need a volunteer to look at it.

The easy way to do this would be to simply take the suggestion here: #2793

I was hoping to do a more thorough fix up, because the broken example hightlights some common misunderstandings with how reset work - which I was trying to verify in #2793

I could do this, but not sure I'm the best CSS person to take it on.

@sideshowbarker sideshowbarker removed the needs info This needs more information to review or act on. label Nov 8, 2022
@Josh-Cena Josh-Cena transferred this issue from mdn/content Jun 15, 2024
Copy link

It looks like this is your first issue. Welcome! 👋 One of the project maintainers will be with you as soon as possible. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct.

@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS issues related to CSS examples. effort: medium Task is a medium effort. idle Issues and pull requests with no activity for three months.
Projects
None yet
Development

No branches or pull requests

5 participants