Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
Books and other paged media often use special techniques to display information. Content may be moved to or generated for special areas of the page, such as running heads or footnotes. Generated content within pages, such as tab leaders or cross-references, helps readers navigate within and between pages. CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This draft updates the earlier draft of GCPM and, where content has been moved to other modules, an appendix indicates the current location of each.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-gcpm” in the subject, preferably like this: “[css-gcpm] …summary of comment…”
This document was produced by the CSS Working Group (part of the Style Activity).
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
Paged media have many special requirements for the display of document content, which have evolved over the long history of printed books. Running headers and footers function as aids to navigation. Notes may appear at the bottom of the page, as footnotes. The properties of pages themselves may change based on their content or position in the document. Leaders visually connect related content. Cross-references may require generated text. Some paged media formats such as PDF use bookmarks for navigation.
This module defines new properties and values, so that authors may bring these techniques to paged media.
Name: | string-set |
---|---|
Value: | [[ <custom-ident> <content-list>] [, <custom-ident> <content-list>]* ] | none |
Initial: | none |
Applies to: | all elements, but not pseudo-elements |
Inherited: | no |
Media: | all |
Computed value: | specified value |
Percentages: | N/A |
The string-set property contains one or more pairs, each consisting of an custom identifier (the name of the named string) followed by a content-list describing how to construct the value of the named string.
content-list expands to one or more of the following values, in any order.
content-list = [ <string> | <counter()> | <counters()> | <content()> | attr(<identifier>) ]+
content() = content([text | before | after | first-letter ])
white-space: normal
had been set. This is the default value::before
pseudo-element, determined as if white-space: normal
had been set. ::after
pseudo-element, determined as if white-space: normal
had been set. ::first-letter
pseudo-element The content values of named strings are assigned at the point when the content box of the element is first created (or would have been created if the element’s display value is none). The entry value for a page is the assignment in effect at the end of the previous page. The exit value for a page is the assignment in effect at the end of the current page.
Whenever the value of the element changes, the value of the named string(s) is updated. User agents must be able to recall many values of the named string, as the string() function can return past, current, or future values of the assignment.
<h1>Loomings</h1>
CSS:
h1::before { content: 'Chapter ' counter(chapter); } h1 { string-set: header content(before) ':' content(text); } h1::after { content: '.'; }
The value of the named string “header” will be “Chapter 1: Loomings”.
<section title="Loomings">
CSS:
section { string-set: header attr(title) }
The value of the “header” string will be “Loomings”.
string() = string( <custom-ident> [ , [ first | start | last | first-except] ]? )
The second argument of the string() function is one of the following keywords:
first
is the default value.first
, except that the empty string is used on the page where the value is assigned.@page { size: 15cm 10cm; margin: 1.5cm; @top-left { content: "first: " string(heading, first); } @top-center { content: "start: " string(heading, start); } @top-right { content: "last: " string(heading, last); } } h2 { string-set: heading content() }
The following figures show the first, start, and last assignments of the “heading” string on various pages.
@page { @top { content: element(header); } } h1 { position: running(header); }
In this example, the h1
element is placed in the @top
margin box, complete with formatting and any descendant elements. It does not display in the normal document flow.
position: running(custom-ident)
removes the element (and associated ::before and ::after pseudo-elements) from the normal flow, and makes it available to place in a page margin box using element(). The element inherits from its original position in the document, but does not display there.
Name: | position |
---|---|
New values: | running() |
Media: | paged |
running() = string( <custom-ident> )
HTML:
<p class="rh"><i>Miranda v. Arizona</i> in Context</p> <h2><i>Miranda v. Arizona</i> in Context</h2>
CSS:
@top-center { content: element(heading); } p.rh { position: running(heading); } p.rh::before { content: counter(page) ' / '; }
The element value() can only be used in page margin boxes. And it cannot be combined with other possible values for the content property.
This idea would be much more useful if we could also copy (rather than just move) elements. That would avoid the duplication of HTML in the example above.
Bert Bos has proposed an alternative syntax, which allows both moving and copying elements into running heads. In the example below, h2 elements appear in their normal place in the document, but are also copied into running heads.
h2 { display: block; running: chapter; font-size: 18pt; font-weight: bold; } h2:running { display: inline; font-size: 11pt; font-weight: normal; font-variant: small-caps; letter-spacing: 1pt; } @page { @top-center { content: element(chapter); } }
Name: | running |
---|---|
Value: | <custom-ident> |
Initial: | none |
Applies to: | elements |
Inherited: | no |
Media: | all |
Computed value: | specified value |
Percentages: | N/A |
The element() value of the content property places an element (which has been removed from the normal flow via running()) in a page margin box. Whenever the value of the element changes, the value of element() is updated.
Just as with string(), element() takes an optional keyword to describe which value should be used in the case of multiple assignments on a page. User agents must be able to recall many values, as element() can return past, current, or future values of the assignment.
Name: | content |
---|---|
New values: | element() |
Media: | paged |
element() = string( <custom-ident> [ , [ first | start | last | first-except] ]? )
Footnotes are complex objects (see the footnote section at [dpub-latinreq]), so it will be helpful to define some terms before proceeding.
float: footnote
to that element. This triggers the following actions:
::footnote-call
pseudo-element is inserted in its place, which serves as a reference to the footnote.::footnote-marker
pseudo-element, identifying the footnote, is placed at the beginning of the footnote element. Together this is the footnote body.<p>Though the body was erect, the head was thrown back so that the closed eyes were pointed towards the needle of the tell-tale that swung from a beam in the ceiling.<span class="footnote">The cabin-compass is called the tell-tale, because without going to the compass at the helm, the Captain, while below, can inform himself of the course of the ship.</span></p>
CSS:
@page { @footnote { float: bottom; } } span.footnote { float: footnote; }
Why is float:bottom used with the footnote area? Floating footnotes to the footnote area, and then floating the footnote area itself, seems overly complex, given that implementations don’t allow the footnote area to float anywhere else. Note that some implementations do allow the footnote area to be absolutely positioned.
Name: | float |
---|---|
New values: | footnote |
Media: | paged |
The footnote-display property determines whether a footnote is displayed as a block element or inline element.
Name: | footnote-display |
---|---|
Value: | block | inline | compact |
Initial: | block |
Applies to: | elements |
Inherited: | no |
Media: | paged |
Computed value: | specified value |
Percentages: | N/A |
@footnote
rule. This rule defines a box that, if used, will contain all the footnote elements that appear on that page.
How would one describe this in the grammar of CSS3-Page?
How do footnotes work in multi-column text? Prince uses float: prince-column-footnote
to create a footnote at the bottom of a column rather than the bottom of a page.
Implementations that support footnotes generally support page floats like float: bottom
. Page floats should end up above the footnote area. How might this be specified?
The max-height property on the footnote area limits the size of this area, unless the page contains only footnotes (as may happen on the last page of a document).
Since it is undesirable for a page to consist only of footnotes, user agents may set a default max-height value on the footnote area.
The footnote counter is a predefined counter associated with the footnote element. Its value is the number or symbol used to identify the footnote. This value is used in both the footnote call and the footnote marker. It should be incremented for each footnote.
The footnote counter, like other counters, may use any counter style. Footnotes often use a sequence of symbols.
::footnote-call { content: counter(footnote, symbols('*', '†', '‡', '§')); } ::footnote-marker { content: counter(footnote, symbols('*', '†', '‡', '§')) '. '; }
The footnote counter may be reset on each page.
@page { counter-reset: footnote; @footnote { … } }
Note that the value of the footnote counter should depend on the position of the footnote element in the document tree, not where it is eventually placed. A footnote element may sometimes be placed on the page after the footnote call, but the same counter value must be used for both.
footnote-call
pseudo-element
::footnote-call
pseudo-element is inserted in place of the footnote element when the latter is removed from the flow. By default, the content of this pseudo-element is the value of the footnote counter, styled as a superscripted number.
::footnote-call { content: counter(footnote); vertical-align: baseline; font-size: 100%; line-height: inherit; font-variant-position: super; }
footnote-marker
pseudo-element
::footnote-marker
pseudo-element represents the footnote element’s marker, the number or symbol that identifies each footnote. This pseudo-element behaves like a ::marker
pseudo-element, as defined in [CSS3LIST]. It is placed at the beginning of the superior parent’s content, and is inline by default. The ::footnote-marker
can be styled just as other ::marker
elements can be. The default style should include list-style-position: inside
.
::footnote-marker { content: counter(footnote); } ::footnote-marker::after { content: '. '; }
footnote policy
Rendering footnotes can be complex. If a footnote falls near the bottom of the page, there may not be enough room on the page for the footnote body. The footnote-policy property allows authors some influence over the rendering of difficult pages.
Name: | footnote-policy |
---|---|
Value: | auto | line | block |
Initial: | auto |
Applies to: | elements |
Inherited: | no |
Media: | paged |
Computed value: | specified value |
Percentages: | N/A |
We need an algorithm for laying out footnotes
nth() = ( An+B [of <custom-ident>]?)
nth() is not related to the page counter, which may reset and use various numbering schemes.
When the nth() selector is applied to a named page, and that named page is part of a page-group (see below), it selects the nth page in the page group.
@page :nth(1)This selects the first page of the document.
@page :nth(2n)This selects all even document pages.
When the page property is applied to an element that also has a forced break property applied, a page group is created. The page group is the collection of all pages created by an instance of that element. When a new instance of the element is rendered, a new page group is started.
A page may be part of several page groups, as a given page group may have ancestors or descendants that are part of another page group.
div { page: A } child { page: B }
@page :nth(5 of A) /* will select 5th page of every <div> */ @page :nth(1 of B) /* will select first page of every <child> */ @page :nth(5) /* will select 5th page of document */
Consider the following HTML:
<div class="chapter"> <h1>Chapter One</h1> <p>some text</p> <table class="broadside"> ... </table> ... </div> <div class="chapter"> <h1>Chapter Two</h1> <p>some text</p> ... <table class="broadside"> ... </table> ... </div>
And CSS:
div.Chapter { page: body; } div.broadside { page: broadside; }
In this case, each chapter will form a separate page group. @page:nth(3 of body) will select the third page of each chapter, even if that page happens to use the “broadside” named page. @page:nth(1) will select only the first page of the document, as will @page:first.
Name: | content |
---|---|
New values: | leader() |
Media: | paged |
leader() = leader( [dotted | solid | space] | <string>);
Three keywords are shorthand values for common strings:
ol.toc a::after { content: leader('.') target-counter(attr(href url), page); } <h1>Table of Contents</h1> <ol class="toc"> <li><a href="#chapter1">Loomings</a></li> <li><a href="#chapter2">The Carpet-Bag</a></li> <li><a href="#chapter3">The Spouter-Inn</a></li> </ol>This might result in:
Table of Contents 1. Loomings.....................1 2. The Carpet-Bag...............9 3. The Spouter-Inn.............13
Do leaders depend on the assumption that the content after the leader is right-aligned (end-aligned)?
BBBBBBBBBB BBB
BBBBBBBBBB ..........
BBBBBBBBBB BBB....AAA
BBBBBBB BBBBBBAInsert a line break before the after content, draw the leader on the next line, and draw the end content on top
BBBBBBB BBBBBB ......A
These functions only take a fragment URL which points to a location in the current document. If there’s no fragment, if the ID referenced isn’t there, or if the URL points to an outside document, the user agent must treat that as an error.
target-counter() = target-counter( <url> , <custom-ident> [ , <counter-style> ]? )
…which will be discussed on page <a href="#chapter4_sec2">000</a>.
CSS:
a::after { content: target-counter(attr(href url), page) }
Result:
…which will be discussed on page 137.
HTML:
<nav> <ol> <li class="frontmatter"><a href="#pref_01">Preface</a></li> <li class="frontmatter"><a href="#intr_01">Introduction</a></li> <li class="bodymatter"><a href="#chap_01">Chapter One</a></li> </ol> </nav>
CSS:
.frontmatter a::after { content: leader('.') target-counter(attr(href url), page, lower-roman) } .bodymatter a::after { content: leader('.') target-counter(attr(href url), page, decimal) }
Result:
Preface.............vii Introduction.........xi Chapter One...........1
target-counters() = target-counter( <url> , <custom-ident> , <string> [ , <counter-style> ]? )
I have not found a compelling example for target-counters() yet.
target-text() = target-counter( <url> [ , [ content | before | after | first-letter] ]? )
A simpler syntax has been proposed by fantasai: http://lists.w3.org/Archives/Public/www-style/2012Feb/0745.html
…which will be discussed <a href="#chapter_h1_1">later</a>. a::after { content: ", in the chapter entitled " target-text(attr(href url)) }Result: …which will be discussed later, in the chapter entitled Loomings.
Name: | bookmark-level |
---|---|
Value: | none | <integer> |
Initial: | none |
Applies to: | all elements |
Inherited: | no |
Media: | paged |
Computed value: | specified value |
Percentages: | N/A |
section h1 { bookmark-level: 1; } section section h1 { bookmark-level: 2; } section section section h1 { bookmark-level: 3; }
Name: | bookmark-label |
---|---|
Value: | <content-list> | none |
Initial: | none |
Applies to: | all elements |
Inherited: | no |
Media: | paged |
Computed value: | specified value |
Percentages: | N/A |
<h1>Loomings</h1>
CSS:
h1 { bookmark-label: content(text); bookmark-level: 1; }
The bookmark label will be “Loomings”.
Name: | bookmark-state |
---|---|
Value: | open | closed |
Initial: | open |
Applies to: | block-level elements |
Inherited: | no |
Media: | paged |
Computed value: | specified value |
Percentages: | N/A |
Many sections which were in the 29 November 2011 Working Draft have been moved to other specifications. Here are some notes on where things have moved.
This section has been moved to CSS Paged Media Module Level 3.
This section has been moved to CSS Color Module Level 4.
This section has been moved to CSS Paged Media Module Level 3
This section has been moved to CSS Overflow Module Level 3.
This is discussed in WHATWG CSS Books.
This section has been moved to CSS Page Floats.
A brief mention of selecting columns is found in WHATWG CSS Books.
This appendix is informative, and is to help UA developers to implement a default stylesheet for HTML, but UA developers are free to ignore or modify as appropriate.
@page { counter-reset: footnote; @footnote { counter-increment: footnote; float: bottom; column-span: all; height: auto; } } ::footnote-marker { content: counter(footnote); list-style-position: inside; } ::footnote-marker::after { content: '. '; } ::footnote-call { content: counter(footnote); vertical-align: super; font-size: 65%; } @supports ( font-variant-position: super ) { ::footnote-call { content: counter(footnote); vertical-align: baseline; font-size: 100%; line-height: inherit; font-variant-position: super; } } h1 { bookmark-level: 1 } h2 { bookmark-level: 2 } h3 { bookmark-level: 3 } h4 { bookmark-level: 4 } h5 { bookmark-level: 5 } h6 { bookmark-level: 6 }
Changes since the 24 September 2013 Editor’s Draft are:
Differences with the WHATWG CSS Books specification:
nth()
page pseudo-class and the page-group concept is clarified, which may make the page-group property redundant.
:first
page pseudo-selector to select the first page of a page-group.
range()
page pseudo-class
Chris Lilley, Elika J. Etemad, Alan Stearns, L. David Baron, Bert Bos, and Liam Quin have provided valuable feedback.
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with class="example"
,
like this:
This is an example of an informative example.
Informative notes begin with the word "Note" and are set apart from the
normative text with class="note"
, like this:
Note, this is an informative note.
Conformance to this specification is defined for three conformance classes:
A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.
A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)
An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.
So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.
To avoid clashes with future CSS features, the CSS2.1 specification reserves a prefixed syntax for proprietary and experimental extensions to CSS.
Prior to a specification reaching the Candidate Recommendation stage in the W3C process, all implementations of a CSS feature are considered experimental. The CSS Working Group recommends that implementations use a vendor-prefixed syntax for such features, including those in W3C Working Drafts. This avoids incompatibilities with future changes in the draft.
Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.
To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.
Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.
Name | Value | Initial | Applies to | Inh. | %ages | Media | Computed value |
---|---|---|---|---|---|---|---|
string-set | [[ <custom-ident> <content-list>] [, <custom-ident> <content-list>]* ] | none | none | all elements, but not pseudo-elements | no | N/A | all | specified value |
running | <custom-ident> | none | elements | no | N/A | all | specified value |
footnote-display | block | inline | compact | block | elements | no | N/A | paged | specified value |
footnote-policy | auto | line | block | auto | elements | no | N/A | paged | specified value |
bookmark-level | none | <integer> | none | all elements | no | N/A | paged | specified value |
bookmark-label | <content-list> | none | none | all elements | no | N/A | paged | specified value |
bookmark-state | open | closed | open | block-level elements | no | N/A | paged | specified value |
This idea would be much more useful if we could also copy (rather than just move) elements. That would avoid the duplication of HTML in the example above.
Bert Bos has proposed an alternative syntax, which allows both moving and copying elements into running heads. In the example below, h2 elements appear in their normal place in the document, but are also copied into running heads.
h2 { display: block; running: chapter; font-size: 18pt; font-weight: bold; } h2:running { display: inline; font-size: 11pt; font-weight: normal; font-variant: small-caps; letter-spacing: 1pt; } @page { @top-center { content: element(chapter); } }
Name: | running |
---|---|
Value: | <custom-ident> |
Initial: | none |
Applies to: | elements |
Inherited: | no |
Media: | all |
Computed value: | specified value |
Percentages: | N/A |
float: prince-column-footnote
to create a footnote at the bottom of a column rather than the bottom of a page. ↵ float: bottom
. Page floats should end up above the footnote area. How might this be specified? ↵