Skip to content

[css-lists] Can replaced elements be list items? #4633

@Loirooriol

Description

@Loirooriol

From https://drafts.csswg.org/css-lists/#list-item,

A list item is any element with its display property set to list-item. List items generate ::marker pseudo-elements

What if you have

<ol>
  <svg style="display: list-item"></svg>
  <li>item</li>
</ol>

The <svg> has display: list-item, but it's a replaced element, so it can't originate a ::marker pseudo-element inside. Then, should we still consider it to be a list item that increments the list-item counter?

In Chromium it's not considered to be a list item, so it shows 1. item. This also used to be the case in Firefox until bug 288704 and bug 1539267, now Firefox shows 2. item.

IMO the Firefox behavior seems confusing. Because if I have

<ol>
  <div style="display: none">
    <svg style="display: list-item"></svg>
  </div>
  <li>item</li>
</ol>

then the <svg> still has a computed display value of list-item, but now it shows 1. item like Chromium. So it's not just checking the computed display, I guess it's also checking for being rendered.

For me it makes more sense to require list items to be non-replaced elements. Then (assuming you are not preventing the ::marker from generating boxes via list-style-type or content), if there is a marker box then it means it's a list item, otherwise it's not.

CC @MatsPalmgren @emilio @fantasai

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