- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Mon, 04 Jan 2010 14:13:47 -0500
- To: divya manian <divya.manian@gmail.com>
- CC: www-style list <www-style@w3.org>
On 1/4/10 12:20 PM, divya manian wrote: > The nested element seems to create another counter named section which > has scope for only nth-child pseudo-class (even though they are only > resetting the counter named section). While this seems consistent with > the Candidate Recommendation [2], each browser seems to interpret this > differently. Chrome/Safari/Opera (latest versions) resets that counter > to 1. Firefox resets that to the last number before the counter is > reset. I'm not sure what you mean here... In this testcase, there are counters named "section" scoped to each <ol> and another counter named "section" scoped to the "horse" <li> and all its following sibling and their descendants. Creating that last counter doesn't affect the values of any other counters around; in particular, the outermost "section" counter (the one attached to the outermost <ol>) remains at the value 3. The Webkit behavior of resetting that counter to the value 1 is incorrect per the current spec text; note, however, that the spec here changed at some point in the last few years. It may be that Webkit implements an earlier version. I don't know where you got your Opera result from. Opera 10 shows the same thing as Gecko over here. > The counter-reset set on classes/pseudo-classes is creating a new > scope even though they are overriding the counter-increment specified > on the same element. That's what the spec requires, yes. In particular this part: "resetting a counter in a descendant element or pseudo-element automatically creates a new instance of the counter." In this case, resetting the counter on the <li> (the pseudo-class doesn't matter except insofar as it resets the counter on a particular <li>) creates a new instance of the counter, since the in-scope instance at that point is on the parent of the <li>. -Boris
Received on Monday, 4 January 2010 19:14:20 UTC