- From: Bert Bos <bert@w3.org>
- Date: Sat, 9 Sep 2006 22:34:50 +0200
- To: www-style@w3.org
On Sat, Sep 09, 2006 at 02:53:02PM +0200, Anne van Kesteren wrote:
> It seems that the counters() construct doesn't really address the use case
> of sections and headers. With a structure such as:
>
> <section>
> <h>LEVEL 1</h>
> <section>
> <h>LEVEL 2</h>
> </section>
> <section>
> <h>LEVEL 2</h>
> </section>
> </section>
>
> ... I can't really find the a way to get an outline such as:
>
> 1. LEVEL 1
> 1.1 LEVEL 2
> 1.2 LEVEL 2
The solution with counter() is simple, though:
body {counter-reset: h1}
section {counter-increment: h1; counter-reset: h2}
section h:before {content: counter(h1) ".\2007 "}
section section {counter-increment: h2}
section section h:before {content: counter(h1) "." counter(h2) " "}
Unless there is a requirement that you didn't mention...
Bert
--
Bert Bos ( W 3 C ) http://www.w3.org/
http://www.w3.org/people/bos W3C/ERCIM
bert@w3.org 2004 Rt des Lucioles / BP 93
+33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Received on Saturday, 9 September 2006 20:34:56 UTC