Re: [css-lists][html] <summary> and ::marker

On 04/21/2016 09:24 PM, Tab Atkins Jr. wrote:
> Recently HTML, under advisement from fantasai and I, specified that
> the "disclosure triangle" on a <summary> element (part of the
> <details> element) is displayed using a list marker, by setting
> <summary> to display:list-item.
>
> Unfortunately, this decision came with some additional baggage that
> we're now having to work around in HTML.  In particular:
>
> * display:list-item also automatically increments the list-item
> counter, which is used by HTML's <ol> element.  This meant that using
> a <details> inside of an <ol> would cause the next <li> to jump ahead
> by 2.

There's a simple fix for this, too: make 'display' not set any
magic counters. The HTML UA style sheet can set the 'list-item'
counter in a counter-increment rule. This also makes 'list-item'
less magic. It only affects the creation of ::marker.

Chrome automatically increments items with 'display: list-item';
however Firefox does not.

> I propose a simple solution: rather than having "display:list-item"
> cause the ::marker to be generated, as is specced today, we make
> ::marker *always* exist, identical to ::before.  For normal elements
> you have to explicitly give it a 'content' value, just like ::before.
> "display:list-item" then just makes the ::marker pay attention to the
> list-style-* properties.

As Ting-yu wrote, adding universal pseudo-elements is not "simple".

> fantasai offers an alternate proposal: leave <summary> as is, leave
> the hack for the first problem, but make the list-style-* properties
> actually only apply to the ::marker pseudo, rather than to list items.
> Inheritance ensures that we maintain today's behavior, but HTML can
> then set list-style-position:inside directly on the summary::marker,
> and avoid the second problem entirely.

Full alternate proposal:

   * 'display: list-item' does not magically set a 'list-item'
     counter-increment; this is handled by the HTML UA style sheet

   * 'list-style-*' apply to ::marker, not to list item elements;
     since they inherit setting them on the list item will continue
     to work as expected

This proposal has two advantages:
   * avoids the creation of a universal ::marker element
   * maintains application of 'list-style' properties to styling
     markers, for which these properties are very useful and usable.

If 'list-style' no longer applies to ::marker on <summary>, then
we lose the simple interface that it offers for setting the marker
style via 'list-style-type' and 'list-style-image', and furthermore
we lose control over the position of the marker that is offered by
'list-style-position'.

The **only** complaint about this is the name "list-style" being
applied here. Imho think this is an acceptable suboptimal legacy
situation. I strongly believe the benefits of its interface are
greater than any superficial concern over its name.

~fantasai

Received on Monday, 25 April 2016 20:17:06 UTC