Closed Bug 504426 Opened 15 years ago Closed 15 years ago

CSS Counters seem not to be correctly implemented.

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: pkirkaas, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)

As described in the w3c CSS specification:
http://www.w3.org/TR/CSS2/generate.html#counters

If I've done the CSS right, the sample code in the steps to "reproduce" section below, the html should produce numbered headings and subheadings.  It does this with Opera, but not Firefox.

Sorry if I've made a mistake or misunderstood the specification; but in case this really is a bug, I wanted to report it to help improve Firefox.

Reproducible: Always

Steps to Reproduce:
1.Example File
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html  xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
  body { max-width: 900px; margin-left: auto; margin-right: auto; }
  body {
    counter-reset: ha;      /* Create a chapter counter scope */
}
h1:before {
    content: counter(ha) ": ";
    counter-increment: ha;  /* Add 1 to chapter */
    counter-reset: hb;      /* Set section to 0 */
    counter-reset: hc;      /* Set section to 0 */
    counter-reset: hd;      /* Set section to 0 */
}
h2:before {
    content: counter(ha) "." counter(hb) ": ";
    counter-increment: hb;  /* Add 1 to chapter */
    counter-reset: hc;      /* Set section to 0 */
    counter-reset: hd;      /* Set section to 0 */
}
h3:before {
    content: counter(ha) "." counter(hb) "." counter(hc)": ";
    counter-increment: hc;  /* Add 1 to chapter */
    counter-reset: hd;      /* Set section to 0 */
}

h4:before {
    content: counter(ha) "." counter(hb) "." counter(hc) "." counter(hd)": ";
    counter-increment: hd;  
}
  
</style>

<title>Test CSS Counters</title>
</head>

<body>
<h1> First H1</h1>
<h2> First H2</h2>
<h3>First H3</h3>
<h4>First H4</h4>
<h4>Second H4</h4>
<h2>Second H2 in first H1</h2>
<h1>Second H1</h1>
<h1>Third H1</h1>
<h2>First H2 in second H1</h2>
<h2>Second H2 in Second H1</h2>
<h3>First H3</h3>
<h3>Another H3</h3>
<h3>Yet another H3</h3>
<h4>Now an H4</h4>
<h4>H4</h4>
<h3>H3</h3>
<h4>H4</h4>
</body>


2.
3.
Actual Results:  
1:
1.1:
1.0.1:
1.0.0.1:
1.1:
2:
3:
3.1:
3.1:
3.0.1:
3.0.1:

Expected Results:  
1:
1.1:
1.1.1:
1.1.1.1:
1.1.1.2:
1.2:
2:
3:
3.1:
3.2:
Component: General → Layout
Product: Firefox → Core
QA Contact: general → layout
Do you mean bug 288946 ?
You need to put the counter-resets on the element rather than on its :before pseudo-element.  See http://dbaron.org/cdi-req/ for an example.  If the counter-reset is on the :before, the scope it establishes ends at the end of the element.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Component: Layout → Style System (CSS)
OS: Windows XP → All
QA Contact: layout → style-system
Hardware: x86 → All
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.