Closed
Bug 311535
Opened 20 years ago
Closed 20 years ago
css-generated heading numbering is broken
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: wam2, Assigned: dbaron)
Details
Attachments
(1 file)
|
490 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b5) Gecko/20051006 Firefoxannus/1.4.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b5) Gecko/20051006 Firefox/1.4.1
see the test case from bug 3247:
https://bugzilla.mozilla.org/attachment.cgi?id=83764
Fx 1.5b2 renders:
1 first order Heading
0.1 second order Heading
0.1 second order Heading
1 first order Heading
while it should be:
1 first order Heading
1.1 second order Heading
1.2 second order Heading
2 first order Heading
Reproducible: Always
Updated•20 years ago
|
Assignee: nobody → dbaron
Component: General → Style System (CSS)
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk
Comment 1•20 years ago
|
||
INVALID. That is a broken testcase. The scope is wrong.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
In the above attachment (id=198930), I cut-and-paste the style snippet from an
example in the CSS2 spec. It is meant to number chapters and sections with
"Chapter 1", "1.1", "1.2", etc. Sadly, Firefox 1.5b2 is not able to render it
correctly.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
| Assignee | ||
Comment 4•20 years ago
|
||
CSS2 has incorrect examples in it. I think most of them are fixed in the most
recent CSS2.1 draft, although IIRC there was still one mistake in one of the
counters examples.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago → 20 years ago
Resolution: --- → INVALID
| Assignee | ||
Comment 5•20 years ago
|
||
And the rules we've implemented are those in CSS2.1.
I checked the example from CSS2.1 (W3C Working Draft 13 June 2005) and it does
not work in Fx 1.5b2 either. Indeed, confusing.
For the benefit of those who try to implement this in their web pages, the
simple CSS2.1 that works in Fx is:
h1 {counter-increment: level1;
counter-reset:level2 level3;}
h1:before {content: counter(level1) ". ";}
h2 {counter-increment: level2;
counter-reset:level3;}
h2:before {content: counter(level1) "." counter(level2) ". ";}
h3 {counter-increment: level3;}
h3:before {content: counter(level1) "." counter(level2) "." counter(level3) ". ";}
CSS2.1 supposedly has a smarter way of doing this through a self-nesting
mechanism using the counters() function, but so far I couldn't make it work. All
test-cases I looked at (such as those in bug 3247) are broken when it comes to
heading numbering. It makes you suspect the Fx implementation may be still buggy.
It would be helpful if someone could actually post a working test case using
self-nesting. It seems very few people on the planet know how it's done.
| Assignee | ||
Comment 7•20 years ago
|
||
You can't number Hn using counter nesting, and never could, since they're
siblings. You have to use separate counters. Nesting is useful for numbered lists.
| Assignee | ||
Comment 8•20 years ago
|
||
FWIW, style rules that I used to number Hn elements (starting with H2, since H1
was the document title) are:
html { counter-reset: h2 h3 h4 h5 h6; }
h2:not(.no-num) { counter-reset: h3 h4 h5 h6; counter-increment: h2; }
h3:not(.no-num) { counter-reset: h4 h5 h6; counter-increment: h3; }
h4:not(.no-num) { counter-reset: h5 h6; counter-increment: h4; }
h5:not(.no-num) { counter-reset: h6; counter-increment: h5; }
h6:not(.no-num) { counter-increment: h6; }
h2:not(.no-num):before { content: counter(h2) ". "; }
h3:not(.no-num):before { content: counter(h2) "." counter(h3) ". "; }
h4:not(.no-num):before { content: counter(h2) "." counter(h3) "." counter(h4)
". "; }
h5:not(.no-num):before { content: counter(h2) "." counter(h3) "." counter(h4)
"." counter(h5) ". "; }
h6:not(.no-num):before { content: counter(h2) "." counter(h3) "." counter(h4)
"." counter(h5) "." counter(h6) ". "; }
This is greatly appreciated, thanks. With your permission, I'll use this to
upgrade the CSS2 code in our pages.
| Assignee | ||
Comment 10•20 years ago
|
||
I'd note that the :not(.no-num) bits are even less cross-browser than the
counters use, so you may want to skip that if you have no need for excluding
headings from counters (or even if you do, since you could redo the same thing
other ways).
But I have no problems with that being reused.
Updated•20 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•