W3C home > Mailing lists > Public > www-style@w3.org > April 2005

CSS 2.1: counter-reset in :before elements

From: Allan Sandfeld Jensen <kde@carewolf.com>
Date: Thu, 7 Apr 2005 23:48:37 +0200
To: www-style@w3.org
Message-Id: <200504072348.37677.kde@carewolf.com>

I recently had a bug report from a person who had used the examples presented 
in the CSS 2.1 specification. The problem is that I consider our current 
behaviour correct and it also matches the behaviour of Opera.

The issue regards counter-reset in :before elements such as this (taken from 
the CSS 2.1 specification):
H1:before {
    content: "Chapter " counter(chapter) ". ";
    counter-increment: chapter;  /* Add 1 to chapter */
    counter-reset: section;      /* Set section to 0 */
}
H2:before {
    content: counter(chapter) "." counter(section) " ";
    counter-increment: section;
}

The problem is the nesting rules and the status of pseudo elements. The 
nesting rules state that a counter-reset creates a new instance of the 
counter for its later siblings and children, and the pseudo elements are 
usually treated as children. This combined means that a counter-reset in 
a :before element only affects the children of the element.

So is the example wrong, or is Konqueror and Opera wrong in our implementation 
of counters?

`Allan
Received on Thursday, 7 April 2005 21:48:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:36 GMT