Skip to content

[css-lists-3] Setting the start value of a reversed list #4211

Closed
@fantasai

Description

@fantasai

Note: We currently have #4181 open on reversing the increment in reversed lists.

Currently, the suggestion for mapping HTML reversed list starts to CSS is that HTML injects a counter-reset declaration on the OL element as part of the attribute-to-CSS mapping of the HTML presentational hint cascade level. There is, however, some amount of magic: the UA has to calculate the start number and pass it to CSS as an <integer>, e.g. counter-reset: list-item 4 for a 3-item reversed list.

Doing some calculations to figure out the value to pass to CSS isn't particularly unusual: for example, HTML does some special parsing of colors before passing to color and background-color, and it does some bidi calculations before passing to direction.

What is super magical is that these calculations are currently defined to be dependent on CSS styles, not just on the contents of the markup. See HTML spec. In particular, this case is very strange, as not only is the display: none element skipped, the descendant SPAN is counted (which I personally find very surprising):

<ol reversed>
  <li>one
  <li style="display: none">none
  <li>two <span style="display: list-item">three</span>
  <li>four
</ol>

Some options going forward include:

  • A) We define the preshint mapping as counter-reset: list-item calc(N+1) where N is magically calculated as defined currently⁠—counting all display: list-item descendants, but skipping the contents of any ol/ul/dir/menu elements.
  • B) We define the preshint mapping as counter-reset: list-item calc(N+1) with some reduced amount of HTML+CSS co-dependence for the counting (assuming there's a definition of that that makes sense and is Web-compatible)?
  • C) We define a reverse-counting counter feature, which HTML uses.
  • D) We define CSS syntax to enable magic counting of display: list-item descendants while skipping the contents of any ol/ul/dir/menu elements. HTML maps to that syntax.
  • E) We define CSS syntax to enable counting, but use a simplified definition of what's counted (Option B). HTML maps to that syntax.
  • F) Something else?

Metadata

Metadata

Assignees

No one assigned

    Labels

    HTMLRequires coordination with HTML peoplecss-lists-3Current Work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions