W3C home > Mailing lists > Public > www-style@w3.org > July 2008

RE: setting counter values without opening a scope..

From: Grant, Melinda <melinda.grant@hp.com>
Date: Thu, 24 Jul 2008 17:40:38 +0000
To: Tab Atkins Jr. <jackalmage@gmail.com>, Ludger Buenger <ludger.buenger@realobjects.com>
CC: "www-style@w3.org" <www-style@w3.org>
Message-ID: <763AE400FE923441B74861D534DF25494DBA834115@GVW0433EXB.americas.hpqcorp.net>
Ludger said:
> I.e. I'd expect something like the following to be possible:

> chapter {
>   page-break-before: always;
>   counter-reset: chapterPageCounter 1;
>   string-set: chapterName self;
> }

> @page {
>  counter-increment: chapterPageCounter;
>  @bottom-right {
>     Content: "Page " counter(chapterPageCounter) "of section " open-quote string(chapterName) close-quote;
>  }
> }

See http://dev.w3.org/csswg/css3-page/#page-based-counters, in particular:
"If a counter that has not been reset or incremented within the margin context or the page context is used by counter() or counters() in the margin context, then the resultant value is exactly as if the margin box were an element within the document at the start of the page, inside the deepest element in the normal flow that spans the page break. Use of the counter in this way does not affect the calculation of the counter's value."

You can declare your counter in 'document space' and reference it within 'page space'.

Best wishes,

Melinda
Received on Thursday, 24 July 2008 17:42:35 GMT

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