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

[css-pseudo][css-lists] Allow counter-* in ::marker #5265

Open
Loirooriol opened this issue Jun 25, 2020 · 6 comments
Open

[css-pseudo][css-lists] Allow counter-* in ::marker #5265

Loirooriol opened this issue Jun 25, 2020 · 6 comments

Comments

@Loirooriol
Copy link
Contributor

The ::marker pseudo-element can use

::marker {
  content: counter(my-counter);
}

However, something like counter-increment: my-counter won't work since counter-increment doesn't apply to ::marker. Gotcha, it has to be set in the list item instead.

So I think counter-increment, counter-set and counter-reset should just apply. Counters don't affect layout so there doesn't seem to be any problem.

@Loirooriol Loirooriol added css-lists-3 Current Work css-pseudo-4 Current Work labels Jun 25, 2020
@fantasai
Copy link
Collaborator

fantasai commented Jul 8, 2020

My current thoughts on ::marker's property list is, for simplicity, until we have a layout model for 'outside', we keep it as short as possible while satisfying the main author use cases and implementer concerns. Is there a particular use case you have in mind?

@Loirooriol
Copy link
Contributor Author

I just wanted something like

ol {
  counter-reset: my-counter;
}
::marker {
  counter-increment: my-counter;
  content: "[" counter(my-counter) "]";
}

Sure, I can set counter-increment: my-counter on the li, but then I need another rule :)

Or I could forget about my-counter and just use counter(list-item). However, list-item is not an actual counter in Chromium, so it has some bugs. For example, until recently, it used to be one unit greater than the correct value... https://crbug.com/796961

So it's not a big deal, but it seems unexpected to me that, given ::marker can read counter values, it can't change them. And changing counters seems completely independent of the outside layout model.

@fantasai
Copy link
Collaborator

@Loirooriol Why wouldn't you just set the counter-increment on the li? Wouldn't that make more sense anyway?

@Loirooriol
Copy link
Contributor Author

@fantasai I don't know, when using counters in ::before, it's not uncommon for me to increment them in ::before too, this avoids needing an extra rule. So it just seems a bit unexpected to me that I can't do the same for ::marker.

@fantasai fantasai removed css-lists-3 Current Work css-pseudo-4 Current Work labels Dec 30, 2020
@LeaVerou
Copy link
Member

LeaVerou commented Jan 5, 2021

Seconded @Loirooriol, I also often increment in ::before as well. That said, I'd consider this pretty low priority.

@Loirooriol
Copy link
Contributor Author

@fantasai I think your reasoning from #6005 also applies here:

Probably should apply, mostly about style computation:

  • transitions
  • animations
  • counters
  • quotes

Since they are mostly about style computation rather than layout, they should be fine in ::marker. Transitions and animations are already allowed, counters and quotes are missing. But yeah, low priority.

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

3 participants