Closed Bug 453280 Opened 16 years ago Closed 16 years ago

The CSS content: counter() doesn't work, it keep showing 1

Categories

(Firefox :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 288946

People

(Reporter: sandaimespaceman, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1

When I added the following code:
H2:before
{
	content: counter(paragraph) ". ";
	counter-increment: paragraph;
}
the counter of <h2> doesn't increase, every <h2> kept showing 1. before. On Opera, the counter worked.

Reproducible: Always

Steps to Reproduce:
1.Use
H2:before
{
	content: counter(paragraph) ". ";
	counter-increment: paragraph;
}
2. The counter doesnt increase

Actual Results:  
 The counter doesnt increase

Expected Results:  
The counter should increase as on Opera 9
Test case:
data:text/html,<!DOCTYPE html><html><head><style type="text/css">h2:before{content:counter(paragraph) ". "; counter-increment: paragraph; }</style></head><body><h2>first</h2><h2>second</h2><h2>third</h2></body></html>

I think Gecko is correct here - you need to use counter-reset. See part 12.4.1 of CSS 2.1 specification, "Nested counters and scope": http://www.w3.org/TR/CSS21/generate.html#scope

> If 'counter-increment' or 'content' on an element or pseudo-element refers to a counter that is not in the scope of any 'counter-reset', implementations should behave as though a 'counter-reset' had reset the counter to 0 on that element or pseudo-element. 

Try adding this:

body { counter-reset: paragraph }

Result:
data:text/html,<!DOCTYPE html><html><head><style type="text/css">body{counter-reset:paragraph}h2:before{content:counter(paragraph) ". "; counter-increment: paragraph; }</style></head><body><h2>first</h2><h2>second</h2><h2>third</h2></body></html>
Here's a screenshot of it:
http://i201.photobucket.com/albums/aa124/SpaceMan454624573/sample.png
It shows same source, but Firefox has that bug
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.