Re: [CSS2.1] Counters nesting

On Thursday 2005-06-16 02:52 +0200, Allan Sandfeld Jensen wrote:
> Given the following CSS and HTML snippets:
> 
> root: { counter-reset: item }
> parent: { counter-reset: item; counter-increment: item }
> child, sibling: {counter-increment: item }
> child::after, sibling::after: { content: counter(item) "," counters(item) }

Assuming you meant 'counters(item, ".")' at the end there, since there's
no one-argument form of counters().

> 
> <root>
> <parent>
> 	<child> Should be 2, 1.1 (?): </child>
> 	<child> Should be 3, 1.2 (?): </child>

Your "should be" statements don't make sense.  The declaration 'content:
counter(item) "," counters(item, ".")' can only produce results of the
form "x,y.z" if x is equal to z, since the last part of the counters()
is the same as what counter() produces.

The first child should show "2,0.2" and the second should show "3,0.3".

> </parent>
> <sibling> Is it 2, 3, 4 or even 1.3? </sibling>
> <root>

Assuming that's an </root>. :-)

> What should the sibling show?

It should show "4,0.4".

> In other words does the reset work separately on sibling and children? And is 
> the counter-increment then counted as a child or as a sibling?

I'm not really sure what you mean by either of these questions.

My way of explaining what's going on is:
 * there are two resets, one on "root" and one on "parent".  The second
   of these creates a nested scope.
 * all the increments of the counter are in the scope of the inner
   reset, as are all the uses

-David

-- 
L. David Baron                                <URL: http://dbaron.org/ >
          Technical Lead, Layout & CSS, The Mozilla Foundation

Received on Thursday, 16 June 2005 01:40:11 UTC