8000 csswg-drafts/css-gcpm/Overview.html at eac408e07fb41598e730cc9766cf7fe189899e7e · w3c/csswg-drafts · GitHub
Skip to content
8000

Latest commit

 

History

History
1510 lines (1145 loc) · 89.5 KB

File metadata and controls

1510 lines (1145 loc) · 89.5 KB
<!DOCTYPE html><html lang=en><head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Generated Content for Paged Media Module</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
</head>
<body class=h-entry>
<div class=head>
<p data-fill-with=logo><a class=logo href=http://www.w3.org/>
<img alt=W3C height=48 src=http://www.w3.org/Icons/w3c_home width=72>
</a>
</p>
<h1 class="p-name no-ref" id=title>CSS Generated Content for Paged Media Module</h1>
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20140513>13 May 2014</span></span></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-gcpm/>http://dev.w3.org/csswg/css-gcpm/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-gcpm/>http://dev.w3.org/csswg/css-gcpm/</a><dt>Previous Versions:<dd><a href=https://dvcs.w3.org/hg/csswg/raw-file/6a5c44d11c2b/css-gcpm/Overview.html rel=previous>https://dvcs.w3.org/hg/csswg/raw-file/6a5c44d11c2b/css-gcpm/Overview.html</a><dd><a href=http://www.w3.org/TR/2011/WD-css3-gcpm-20111129/ rel=previous>http://www.w3.org/TR/2011/WD-css3-gcpm-20111129/</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-gcpm%5D%20feedback">www-style@w3.org</a>
with subject line
“<kbd>[css-gcpm] <var>… message topic …</var></kbd>”(<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)<dt>Test Suite:<dd>None Yet<dt>Editors:
<dd class="p-author h-card vcard"><a class="p-name fn u-email email" href=mailto:dave.cramer@hbgusa.com>Dave Cramer</a> (<span class="p-org org">Hachette Livre</span>)<dt>Former Editors:
<dd class="p-author h-card vcard"><span class="p-name fn">Håkon Wium Lie</span> (<span class="p-org org">Opera Software</span>)<dt>Issue Tracking:<dd><a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=CSS&amp;component=Generated%20Content%20for%20Paged%20Media">W3C Bugzilla</a></dl></div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2014 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=abstract><span class=content>Abstract</span></h2>
<p class=p-summary data-fill-with=abstract>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.
<a href=http://www.w3.org/TR/CSS/>CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</p>
<h2 class="no-num no-toc no-ref heading settled heading" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-gcpm%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href=http://www.w3.org/Mail/Request>instructions</a>)
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] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=http://www.w3.org/Style/CSS/members>CSS Working Group</a>
(part of the <a href=http://www.w3.org/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
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 <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc>
<li><a href=#introduction><span class=s 8096 ecno></span> Introduction </a>
<li><a href=#running-headers-and-footers><span class=secno>1</span> Running headers and footers </a>
<ul class=toc>
<li><a href=#named-strings><span class=secno>1.1</span> Named strings </a>
<ul class=toc>
<li><a href=#setting-named-strings-the-string-set-pro><span class=secno>1.1.1</span> The string-set property </a>
<ul class=toc>
<li><a href=#content-function-header><span class=secno>1.1.1.1</span>The <span class=css data-link-type=maybe title=content()>content()</span> function</a></ul>
<li><a href=#using-named-strings><span class=secno>1.1.2</span> The <span class=css data-link-type=maybe title=string()>string()</span> function </a></ul>
<li><a href=#running-elements><span class=secno>1.2</span> Running elements </a>
<ul class=toc>
<li><a href=#running-syntax><span class=secno>1.2.1</span> The <span class=css data-link-type=maybe title=running()>running()</span> value </a>
<li><a href=#element-syntax><span class=secno>1.2.2</span> The <span class=css data-link-type=maybe title=element()>element()</span> value </a></ul></ul>
<li><a href=#footnotes><span class=secno>2</span> Footnotes </a>
<ul class=toc>
<li><a href=#footnote-terms><span class=secno>2.1</span>Terminology</a>
<li><a href=#creating-footnotes><span class=secno>2.2</span> Creating footnotes </a>
<li><a href=#footnote-types><span class=secno>2.3</span> Types of footnotes </a>
<li><a href=#footnote-area><span class=secno>2.4</span> The footnote area </a>
<ul class=toc>
<li><a href=#footnote-area-position><span class=secno>2.4.1</span>Positioning of the footnote area</a>
<li><a href=#footnote-area-size><span class=secno>2.4.2</span>Size of the footnote area</a></ul>
<li><a href=#footnote-counters><span class=secno>2.5</span>The Footnote Counter</a>
<ul class=toc>
<li><a href=#footnote-counter-values><span class=secno>2.5.1</span>Values of the footnote counter</a>
<li><a href=#resetting-footnote-counter><span class=secno>2.5.2</span>Resetting the footnote counter</a></ul>
<li><a href=#footnote-call><span class=secno>2.6</span> The <code>footnote-call</code> pseudo-element </a>
<li><a href=#footnote-marker><span class=secno>2.7</span> The <code>footnote-marker</code> pseudo-element </a>
<li><a href=#footnote-policy><span class=secno>2.8</span> Rendering footnotes and <code>footnote policy</code> </a>
<li><a href=#future><span class=secno>2.9</span> Future directions </a></ul>
<li><a href=#the-first-page-pseudo-element><span class=secno>3</span> Selecting Pages </a>
<ul class=toc>
<li><a href=#document-page-selectors><span class=secno>3.1</span> Page Selectors </a>
<li><a href=#document-sequence-selectors><span class=secno>3.2</span> Page groups </a></ul>
<li><a href=#leaders><span class=secno>4</span> Leaders </a>
<ul class=toc>
<li><a href=#rendering-leaders><span class=secno>4.1</span> Rendering leaders </a>
<ul class=toc>
<li><a href=#procedure-leader><span class=secno>4.1.1</span> Procedure for rendering leaders </a></ul></ul>
<li><a href=#cross-references><span class=secno>5</span> Cross-references </a>
<ul class=toc>
<li><a href=#target-counter><span class=secno>5.1</span> The <span class=css data-link-type=maybe title=target-counter()>target-counter()</span> function </a>
<li><a href=#target-counters><span class=secno>5.2</span> The <span class=css data-link-type=maybe title=target-counters()>target-counters()</span> function </a>
<li><a href=#target-text><span class=secno>5.3</span> target-text </a></ul>
<li><a href=#bookmarks><span class=secno>6</span> Bookmarks </a>
<ul class=toc>
<li><a href=#bookmark-level><span class=secno>6.1</span> bookmark-level </a>
<li><a href=#bookmark-label><span class=secno>6.2</span> bookmark-label </a>
<li><a href=#bookmark-state><span class=secno>6.3</span> bookmark-state </a></ul>
<li><a href=#former-wd-sections><span class=secno></span>Appendix A: Where Are They Now?</a>
<ul class=toc>
<li><a href=#page-marks-and-bleed-area><span class=secno></span>Page marks and bleed area</a>
<li><a href=#cmyk-colors><span class=secno></span>CMYK colors</a>
<li><a href=#styling-blank-pages><span class=secno></span>Styling blank pages</a>
<li><a href=#paged-presentations><span class=secno></span>Paged presentations</a>
<li><a href=#navigation-between-pages><span class=secno></span>Navigation between pages</a>
<li><a href=#page-floats><span class=secno></span>Page floats</a>
<li><a href=#selecting-columns-and-pages><span class=secno></span>Selecting columns and pages</a></ul>
<li><a href=#ua-stylesheet><span class=secno></span>Appendix B: Default UA Stylesheet</a>
<li><a href=#changes><span class=secno></span>Appendix C: Changes</a>
<li><a href=#acknowledgments><span class=secno></span> Acknowledgments </a>
<li><a href=#conformance><span class=secno></span> Conformance</a>
<ul class=toc>
<li><a href=#conventions><span class=secno></span> Document conventions</a>
<li><a href=#conformance-classes><span class=secno></span> Conformance classes</a>
<li><a href=#partial><span class=secno></span> Partial implementations</a>
<li><a href=#experimental><span class=secno></span> Experimental implementations</a>
<li><a href=#testing><span class=secno></span> Non-experimental implementations</a></ul>
<li><a href=#references><span class=secno></span> References</a>
<ul class=toc>
<li><a href=#normative><span class=secno></span> Normative References</a>
<li><a href=#informative><span class=secno></span> Informative References</a></ul>
<li><a href=#index><span class=secno></span> Index</a>
<li><a href=#property-index><span class=secno></span> Property index</a>
<li><a href=#issues-index><span class=secno></span>Issues Index</a></ul></div>
<h2 class="no-num heading settled heading" id=introduction><span class=content>
Introduction
</span></h2>
<p>Paged media have many <a href=http://w3c.github.io/dpub-pagination/index.html>special requirements</a> 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.</p>
<p>This module defines new properties and values, so that authors may bring these techniques to paged media.</p>
<h2 class="heading settled heading" data-level=1 id=running-headers-and-footers><span class=secno>1 </span><span class=content>
Running headers and footers
</span><a class=self-link href=#running-headers-and-footers></a></h2>
<a data-biblio-type=informative data-link-type=biblio href=#css3page title=css3page>[CSS3PAGE]</a> describes the sixteen page margin boxes which can be used for running headers and footers, but does not describe a mechanism for inserting content in those boxes. This module provides two methods for for doing so. <dfn data-dfn-type=dfn data-noexport="" id=named-strings0 title="named string">Named strings<a class=self-link href=#named-strings0></a></dfn> copy text for reuse in margin boxes. <dfn data-dfn-type=dfn data-noexport="" id=running-elements0>Running elements<a class=self-link href=#running-elements0></a></dfn> move elements (complete with style and structure) from the document to margin boxes.
<h3 class="heading settled heading" data-level=1.1 id=named-strings><span class=secno>1.1 </span><span class=content>
Named strings
</span><a class=self-link href=#named-strings></a></h3>
The <a class=property data-link-type=propdesc href=#propdef-string-set title=string-set>string-set</a> property copies the text content of an element into a <a class=css data-link-type=maybe href=#named-strings0 title="named string">named string</a>, which functions as a variable. The text content of this named string can be retrieved using the <a class=css data-link-type=maybe href=#funcdef-string title=string()>string()</a> function. Since these variables may change on a given page, an optional second value for the <a class=css data-link-type=maybe href=#funcdef-string title=string()>string()</a> function allows authors to choose which value on a page is used.
<h4 class="heading settled heading" data-level=1.1.1 id=setting-named-strings-the-s 133E tring-set-pro><span class=secno>1.1.1 </span><span class=content>
The string-set property
</span><a class=self-link href=#setting-named-strings-the-string-set-pro></a></h4>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-string-set>string-set<a class=self-link href=#propdef-string-set></a></dfn><tr><th>Value:<td class=prod>[[ <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a> <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-content-3/#ltcontent-listgt title="<content-list>">&lt;content-list&gt;</a>] [, <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a> <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-content-3/#ltcontent-listgt title="<content-list>">&lt;content-list&gt;</a>]* ] | none<tr><th>Initial:<td>none<tr><th>Applies to:<td>all elements, but not pseudo-elements<tr><th>Inherited:<td>no<tr><th>Media:<td>all<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>N/A</table>
<p>The <a class=property data-link-type=propdesc href=#propdef-string-set title=string-set>string-set</a> property contains one or more pairs, each consisting of an custom identifier (the name of the named string) followed by a <a class=css data-link-type=maybe href=#content-list title=content-list>content-list</a> describing how to construct the value of the named string.</p>
<p><a class=css data-link-type=maybe href=#content-list title=content-list>content-list</a> expands to one or more of the following values, in any order.</p>
<pre class=prod> <dfn data-dfn-type=dfn data-noexport="" id=content-list>content-list<a class=self-link href=#content-list></a></dfn> = [ &lt;string&gt; | &lt;counter()&gt; | &lt;counters()&gt; | &lt;content()&gt; | attr(<identifier>) ]+
</identifier></pre>
<dl data-dfn-for=content-list data-dfn-type=value>
<dt> &lt;string&gt; </dt>
<dd> A <a href=http://www.w3.org/TR/CSS21/syndata.html#strings>string</a>, as defined in <a data-biblio-type=informative data-link-type=biblio href=#css21 title=css21>[CSS21]</a> </dd>
<dt> &lt;counter()&gt; </dt>
<dd> A <a href=http://www.w3.org/TR/CSS21/syndata.html#counter>counter()</a> function, as described in <a data-biblio-type=informative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>.</dd>
<dt> &lt;counters()&gt; </dt>
<dd> A <a href=http://www.w3.org/TR/CSS21/syndata.html#counter>counters()</a> function, as described in <a data-biblio-type=informative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>.</dd>
<dt>content()</dt>
<dd>The <a class=css data-link-type=maybe href=#funcdef-content title=content()>content()</a> function, described below.</dd>
<dt>attr(&lt;identifier&gt;)</dt>
<dd>Returns the string value of the attribute &lt;identifier&gt;, as defined in <a data-biblio-type=informative data-link-type=biblio href=#css3val title=css3val>[CSS3VAL]</a></dd>
</dl>
<h5 class="heading settled heading" data-level=1.1.1.1 id=content-function-header><span class=secno>1.1.1.1 </span><span class=content>The <a class=css data-link-type=maybe href=#funcdef-content title=content()>content()</a> function</span><a class=self-link href=#content-function-header></a></h5>
<pre class=prod> <dfn class=css-code data-dfn-type=function data-export="" id=funcdef-content>content()<a class=self-link href=#funcdef-content></a></dfn> = content([text | before | after | first-letter ])
</pre>
<dl data-dfn-for=content() data-dfn-type=value>
<dt>text</dt>
<dd>The string value of the element, determined as if <code>white-space: normal</code> had been set. This is the default value</dd>
<dt>before</dt>
<dd>The string value of the <code>::before</code> pseudo-element, determined as if <code>white-space: normal</code> had been set. </dd>
<dt>after</dt>
<dd>The string value of the <code>::after</code> pseudo-element, determined as if <code>white-space: normal</code> had been set. </dd>
<dt>first-letter</dt>
<dd>The first letter of the element, as defined for the <code><a href=http://www.w3.org/TR/css3-selectors/#first-letter>::first-letter</a></code> pseudo-element </dd>
</dl>
<p>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 <dfn data-dfn-type=dfn data-noexport="" id=entry-value>entry value<a class=self-link href=#entry-value></a></dfn> for a page is the assignment in effect at the end of the previous page. The <dfn data-dfn-type=dfn data-noexport="" id=exit-value>exit value<a class=self-link href=#exit-value></a></dfn> for a page is the assignment in effect at the end of the current page.</p>
<p>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 <a class=css data-link-type=maybe href=#funcdef-string title=string()>string()</a> function can return past, current, or future values of the assignment.
<div class=example>
HTML:
<pre>&lt;h1&gt;Loomings&lt;/h1&gt;
<p>CSS:
<pre>h1::before { content: 'Chapter ' counter(chapter); }
h1 { string-set: header content(before) ':' content(text); }
h1::after { content: '.'; }
<p>The value of the named string “header” will be “Chapter 1: Loomings”.
</pre></pre></div><p></p>
<div class=example>
HTML:
<pre>&lt;section title="Loomings"&gt;
</pre>
<p>CSS:
<pre>section { string-set: header attr(title) }
<p>The value of the “header” string will be “Loomings”.
</pre></div><p></p>
<h4 class="heading settled heading" data-level=1.1.2 id=using-named-strings><span class=secno>1.1.2 </span><span class=content>
The <a class=css data-link-type=maybe href=#funcdef-string title=string()>string()</a> function
</span><a class=self-link href=#using-named-strings></a></h4>
The <a class=css data-link-type=maybe href=#funcdef-string title=string()>string()</a> function is used to copy the value of a named string to the document, via the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-content-3/#content title=content>content</a> property. This function requires one argument, the name of the named string. Since the value of a named string may change several times on a page (as new instances of the element defining the string appear) an optional second argument indicates which value of the named string should be used.
<pre class=prod> <dfn class=css-code data-dfn-type=function data-export="" id=funcdef-string>string()<a class=self-link href=#funcdef-string></a></dfn> = string( <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a> [ , [ first | start | last | first-except] ]? )
</pre>
<p>The second argument of the <a class=css data-link-type=maybe href=#funcdef-string title=string()>string()</a> function is one of the following keywords:
<dl data-dfn-for=string() data-dfn-type=value>
<dt id=string-first><a class=self-link href=#string-first></a>first</dt>
<dd>The value of the first assignment on the page is used. If there is no assignment on the page, the <a class=css data-link-type=maybe href=#entry-value title="entry value">entry value</a> is used. <code>first</code> is the default value.</dd>
<dt id=string-start><a class=self-link href=#string-start></a>start</dt>
<dd>If the element is the first element on the page, the value of the first assignment is used. Otherwise the <a class=css data-link-type=maybe href=#entry-value title="entry value">entry value</a> is used. The <a class=css data-link-type=maybe href=#entry-value title="entry value">entry value</a> may be empty if the element hasn’t yet appeared. </dd>
<dt id=string-last><a class=self-link href=#string-last></a>last</dt>
<dd>The <a class=css data-link-type=maybe href=#exit-value title="exit value">exit value</a> of the named string is used.</dd>
<dt id=string-first-except><a class=self-link href=#string-first-except></a>first-except</dt>
<dd>This is identical to <code>first</code>, except that the empty string is used on the page where the value is assigned.</dd>
</dl><p></p>
<div class=example>
CSS:
<pre>@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() }
</pre>
<p>The following figures show the first, start, and last assignments of the “heading” string on various pages.
</p><figure>
<img alt="" src=using-strings-1.jpg width=480>
<figcaption>The <a href=#string-start>start</a> value is empty, as the string had not yet been set at the start of the page.</figcaption>
</figure>
<figure>
<img alt="" src=using-strings-2.jpg width=480>
<figcaption>Since the page starts with an h2, the <a href=#string-start>start</a> value is the value of that head.</figcaption>
</figure>
<figure>
<img alt="" src=using-strings-3.jpg width=480>
<figcaption>Since there’s not an h2 at the top of this page, the <a href=#string-start>start</a> value is the <a class=css data-link-type=maybe href=#exit-value title="exit value">exit value</a> of the previous page.</figcaption>
</figure><p></p>
</div>
<h3 class="heading settled heading" data-level=1.2 id=running-elements><span class=secno>1.2 </span><span class=content>
Running elements
</span><a class=self-link href=#running-elements></a></h3>
Many headers and footers cannot be represented only by unformatted text. A book title serving as a running head may contain an italic word, for example. A mechanism is needed to move or copy elements into margin boxes. To do this, we add the <a class=css data-link-type=maybe href=#funcdef-running title=running()>running()</a> value to the position property, and the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> value to the content property.
<div class=example>
<pre>@page {
@top { content: element(header); }
}
h1 { position: running(header); }
</pre>
In this example, the <code>h1</code> element is placed in the <code>@top</code> margin box, complete with formatting and any descendant elements. It does not display in the normal document flow.
</div>
<h4 class="heading settled heading" data-level=1.2.1 id=running-syntax><span class=secno>1.2.1 </span><span class=content>
The <a class=css data-link-type=maybe href=#funcdef-running title=running()>running()</a> value
</span><a class=self-link href=#running-syntax></a></h4>
<code>position: running(custom-ident)</code> 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 <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a>. The element inherits from its original position in the document, but does not display there.
<table class="definition propdef partial"><tr><th>Name:<td><a class=css-code data-link-type=property href=http://dev.w3.org/csswg/css-position-3/#position title=position>position</a><tr><th>New values:<td>running()<tr><th>Media:<td>paged</table>
<pre class=prod> <dfn class=css-code data-dfn-type=function data-export="" id=funcdef-running>running()<a class=self-link href=#funcdef-running></a></dfn> = string( <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a> )
</pre>
<p></p>
<div class=example>
<p>HTML:
<pre>&lt;p class="rh"&gt;&lt;i&gt;Miranda v. Arizona&lt;/i&gt; in Context&lt;/p&gt;
&lt;h2&gt;&lt;i&gt;Miranda v. Arizona&lt;/i&gt; in Context&lt;/h2&gt;
<p>CSS:
<pre> @top-center {
content: element(heading);
}
p.rh {
position: running(heading);
}
p.rh::before {
content: counter(page) ' / ';
}
<figure>
<p><img alt="running header using running elements" src=running-element-gcpm_Page_1.jpg width=480>
</p><figcaption>Running element in page margin box</figcaption>
</figure>
</pre></pre></div><p></p>
<p class=note>The element <span class=css data-link-type=maybe title=value()>value()</span> can only be used in page margin boxes. And it cannot be combined with other possible values for the content property.</p>
<div class=issue id=issue-4977ffe9><a class=self-link href=#issue-4977ffe9></a>
<p>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.
</p>
<p>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.</p>
<div class=example>
<pre>
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);
}
}
</pre>
</div>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-running>running<a class=self-link href=#propdef-running></a></dfn><tr><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a><tr><th>Initial:<td>none<tr><th>Applies to:<td>elements<tr><th>Inherited:<td>no<tr><th>Media:<td>all<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>N/A</table>
</div>
<h4 class="heading settled heading" data-level=1.2.2 id=element-syntax><span class=secno>1.2.2 </span><span class=content>
The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> value
</span><a class=self-link href=#element-syntax></a></h4>
<p>The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> value of the content property places an element (which has been removed from the normal flow via <a class=css data-link-type=maybe href=#funcdef-running title=running()>running()</a>) in a page margin box. Whenever the value of the element changes, the value of <a class=c 6D50 ss data-link-type=maybe href=#funcdef-element title=element()>element()</a> is updated.</p>
<p>Just as with <a class=css data-link-type=maybe href=#funcdef-string title=string()>string()</a>, <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> 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 <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> can return past, current, or future values of the assignment.</p>
<table class="definition propdef partial"><tr><th>Name:<td><a class=css-code data-link-type=property href=http://dev.w3.org/csswg/css-content-3/#content title=content>content</a><tr><th>New values:<td>element()<tr><th>Media:<td>paged</table>
<pre class=prod> <dfn class=css-code data-dfn-type=function data-export="" id=funcdef-element>element()<a class=self-link href=#funcdef-element></a></dfn> = string( <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a> [ , [ first | start | last | first-except] ]? )
</pre>
<h2 class="heading settled heading" data-level=2 id=footnotes><span class=secno>2 </span><span class=content>
Footnotes
</span><a class=self-link href=#footnotes></a></h2>
Ancillary content may be moved to the bottom or side of a page. A footnote is created when such content moves to the bottom of the page, leaving a reference indicator.
<h3 class="heading settled heading" data-level=2.1 id=footnote-terms><span class=secno>2.1 </span><span class=content>Terminology</span><a class=self-link href=#footnote-terms></a></h3>
<p>Footnotes are complex objects (see the <a href=http://www.w3.org/TR/2014/WD-dpub-latinreq-20140313/#footnotes>footnote section</a> at <a data-biblio-type=informative data-link-type=biblio href=#dpub-latinreq title=dpub-latinreq>[dpub-latinreq]</a>), so it will be helpful to define some terms before proceeding.</p>
<figure>
<p><img alt="page with footnotes" src=footnote-diagram.001.jpg width=480>
</p><figcaption>Footnote terminology</figcaption>
</figure><p></p>
<dl>
<dt>footnote element</dt>
<dd>The element containing the content of the footnote, which will be removed from the flow and displayed as a footnote.</dd>
<dt>footnote marker (also known as footnote number)</dt>
<dd>A number or symbol adjacent to the footnote body, identifying the particular footnote. The footnote marker should use the same number or symbol as the corresponding footnote call, although the marker may contain additional punctuation.</dd>
<dt>footnote body</dt>
<dd>The footnote marker is placed before the footnote element, and together they represent the footnote body, which will be placed in the footnote area.</dd>
<dt>footnote call (also known as footnote reference)</dt>
<dd>A number or symbol, found in the main text, which points to the footnote body.</dd>
<dt>footnote area</dt>
<dd>The page area used to display footnotes.</dd>
<dt>footnote rule (also known as footnote separator)</dt>
<dd>A horizontal rule is often used to separate the footnote area from the rest of the page. The separator (and the entire footnote area) cannot be rendered on a page with no footnotes.</dd>
</dl>
<h3 class="heading settled heading" data-level=2.2 id=creating-footnotes><span class=secno>2.2 </span><span class=content>
Creating footnotes
</span><a class=self-link href=#creating-footnotes></a></h3>
An element becomes a footnote by applying <code>float: footnote</code> to that element. This triggers the following actions:
<ol>
<li> The footnote element is removed from the flow, and a <code>::footnote-call</code> pseudo-element is inserted in its place, which serves as a reference to the footnote.</li>
<li> A <code>::footnote-marker</code> pseudo-element, identifying the footnote, is placed at the beginning of the footnote element. Together this is the footnote body.</li>
<li>The <a class=css data-link-type=maybe href=#footnote-counter title="footnote counter">footnote counter</a> is incremented.</li>
<li>The footnote body is placed in the footnote area at the bottom of the page. Footnote elements from a given page are placed in the footnote area of that page in document order.</li>
</ol>
<div class=example>
HTML:
<pre style="word-wrap: break-word; white-space: pre-wrap;">&lt;p&gt;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.&lt;span class="footnote"&gt;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.&lt;/span&gt;&lt;/p&gt;
</pre>
<p>CSS:
<pre>@page {
@footnote {
float: bottom;
}
}
span.footnote { float: footnote; }
</pre></div>
<p class=issue id=issue-4af1f674><a class=self-link href=#issue-4af1f674></a>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.</p>
<h3 class="heading settled heading" data-level=2.3 id=footnote-types><span class=secno>2.3 </span><span class=content>
Types of footnotes
</span><a class=self-link href=#footnote-types></a></h3>
The following new value of the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-float title=float>float</a> property creates a footnote element:
<table class="definition propdef partial"><tr><th>Name:<td><a class=css-code data-link-type=property href=http://dev.w3.org/csswg/css2/visuren.html#propdef-float title=float>float</a><tr><th>New values:<td>footnote<tr><th>Media:<td>paged</table>
<dl data-dfn-for=float data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=float data-dfn-type=value data-export="" id=valuedef-footnote>footnote<a class=self-link href=#valuedef-footnote></a></dfn></dt>
<dd>each footnote element is placed in the footnote area of the page</dd>
</dl>
<p>The <a class=property data-link-type=propdesc href=#propdef-footnote-display title=footnote-display>footnote-display</a> property determines whether a footnote is displayed as a block element or inline element.</p>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-footnote-display>footnote-display<a class=self-link href=#propdef-footnote-display></a></dfn><tr><th>Value:<td class=prod>block | inline | compact<tr><th>Initial:<td>block<tr><th>Applies to:<td>elements<tr><th>Inherited:<td>no<tr><th>Media:<td>paged<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>N/A</table>
<dl data-dfn-for=footnote-display data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=footnote-display data-dfn-type=value data-export="" id=footnote-display-block>block<a class=self-link href=#footnote-display-block></a></dfn></dt>
<dd>The footnote element is placed in the footnote area as a block element</dd>
<dt><dfn class=css-code data-dfn-for=footnote-display data-dfn-type=value data-export="" id=footnote-display-inline>inline<a class=self-link href=#footnote-display-inline></a></dfn></dt>
<dd>The footnote element is placed in the footnote area as an inline element</dd>
<dt><dfn class=css-code data-dfn-for=footnote-display data-dfn-type=value data-export="" id=footnote-display-compact>compact<a class=self-link href=#footnote-display-compact></a></dfn></dt>
<dd>The user agent determines whether a given footnote element is placed as a block element or an inline element. If two or more footnotes could fit on the same line in the footnote area, they should be placed inline.</dd>
</dl>
<h3 class="heading settled heading" data-level=2.4 id=footnote-area><span class=secno>2.4 </span><span class=content>
The footnote area
</span><a class=self-link href=#footnote-area></a></h3>
A <a href=http://dev.w3.org/csswg/css-page/#page-area>page area</a> that can be used to display footnotes is described in the <a href=http://dev.w3.org/csswg/css-page/#page-context>page context</a> using an <code>@footnote</code> rule. This rule defines a box that, if used, will contain all the footnote elements that appear on that page. <p></p>
<p class=issue id=issue-829ce977><a class=self-link href=#issue-829ce977></a>How would one describe this in the grammar of CSS3-Page?</p>
<h4 class="heading settled heading" data-level=2.4.1 id=footnote-area-position><span class=secno>2.4.1 </span><span class=content>Positioning of the footnote area</span><a class=self-link href=#footnote-area-position></a></h4>
The bottom margin edge of the footnote area is positioned so that it touches the bottom of the page area. The footnote area can only contain footnotes.
<p class=issue id=issue-ab22b570><a class=self-link href=#issue-ab22b570></a>How do footnotes work in multi-column text? Prince uses <code>float: prince-column-footnote</code> to create a footnote at the bottom of a column rather than the bottom of a page.</p>
<p class=issue id=issue-165f8769><a class=self-link href=#issue-165f8769></a>Implementations that support footnotes generally support page floats like <code>float: bottom</code>. Page floats should end up above the footnote area. How might this be specified?</p>
<h4 class="heading settled heading" data-level=2.4.2 id=footnote-area-size><span class=secno>2.4.2 </span><span class=content>Size of the footnote area</span><a class=self-link href=#footnote-area-size></a></h4>
<p>The <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-max-height title=max-height>max-height</a> 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).</p>
<p>Since it is undesirable for a page to consist only of footnotes, user agents <em class=RFC2119>may</em> set a default max-height value on the footnote area.</p>
<h3 class="heading settled heading" data-level=2.5 id=footnote-counters><span class=secno>2.5 </span><span class=content>The Footnote Counter</span><a class=self-link href=#footnote-counters></a></h3>
<p>The <dfn data-dfn-type=dfn data-noexport="" id=footnote-counter>footnote counter<a class=self-link href=#footnote-counter></a></dfn> is a predefined <a href=http://dev.w3.org/csswg/css-lists/#counter>counter</a> 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.</p>
<h4 class="heading settled heading" data-level=2.5.1 id=footnote-counter-values><span class=secno>2.5.1 </span><span class=content>Values of the footnote counter</span><a class=self-link href=#footnote-counter-values></a></h4>
<p>The footnote counter, like other counters, may use any <a href=http://dev.w3.org/csswg/css-counter-styles-3/#counter-style>counter style</a>. Footnotes often use a sequence of symbols.</p>
<div class=example>
<pre>::footnote-call { content: counter(footnote, symbols('*', '†', '‡', '§')); }
::footnote-marker { content: counter(footnote, symbols('*', '†', '‡', '§')) '. '; }
</pre>
</div>
<h4 class="heading settled heading" data-level=2.5.2 id=resetting-footnote-counter><span class=secno>2.5.2 </span><span class=content>Resetting the footnote counter</span><a class=self-link href=#resetting-footnote-counter></a></h4>
<p>The footnote counter may be reset on each page.</p>
<div class=example>
<pre>@page {
counter-reset: footnote;
@footnote { … }
}
</pre>
</div>
<p>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.</p>
<h3 class="heading settled heading" data-level=2.6 id=footnote-call><span class=secno>2.6 </span><span class=content>
The <code>footnote-call</code> pseudo-element
</span><a class=self-link href=#footnote-call></a></h3>
A <code>::footnote-call</code> 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.
<div class=example>
<pre>::footnote-call {
content: counter(footnote);
vertical-align: baseline;
font-size: 100%;
line-height: inherit;
font-variant-position: super;
}
</pre>
</div>
<h3 class="heading settled heading" data-level=2.7 id=footnote-marker><span class=secno>2.7 </span><span class=content>
The <code>footnote-marker</code> pseudo-element
</span><a class=self-link href=#footnote-marker></a></h3>
The <code>::footnote-marker</code> pseudo-element represents the footnote element’s marker, the number or symbol that identifies each footnote. This pseudo-element behaves like a <code>::marker</code> pseudo-element, as defined in <a data-biblio-type=informative data-link-type=biblio href=#css3list title=css3list>[CSS3LIST]</a>. It is placed at the beginning of the superior parent’s content, and is inline by default. The <code>::footnote-marker</code> can be styled just as other <code>::marker</code> elements can be. The default style should include <code>list-style-position: inside</code>.
<div class=example>
<pre>::footnote-marker {
content: counter(footnote);
}
::footnote-marker::after {
content: '. ';
}
</pre>
</div>
<h3 class="heading settled heading" data-level=2.8 id=footnote-policy><span class=secno>2.8 </span><span class=content>
Rendering footnotes and <code>footnote policy</code>
</span><a class=self-link href=#footnote-policy></a></h3>
<p>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 <a class=property data-link-type=propdesc href=#propdef-footnote-policy title=footnote-policy>footnote-policy</a> property allows authors some influence over the rendering of difficult pages.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-footnote-policy>footnote-policy<a class=self-link href=#propdef-footnote-policy></a></dfn><tr><th>Value:<td class=prod>auto | line | block<tr><th>Initial:<td>auto<tr><th>Applies to:<td>elements<tr><th>Inherited:<td>no<tr><th>Media:<td>paged<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>N/A
<dl data-dfn-for=footnote-policy data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=footnote-policy data-dfn-type=value data-export="" id=valuedef-auto>auto<a class=self-link href=#valuedef-auto></a></dfn></dt>
<dd>The user agent chooses how to render footnotes, and may place the footnote body on a later page than the footnote reference. A footnote body must never be placed on a page before the footnote reference.</dd>
<dt><dfn class=css-code data-dfn-for=footnote-policy data-dfn-type=value data-export="" id=footnote-policy-line>line<a class=self-link href=#footnote-policy-line></a></dfn></dt>
<dd>If a given footnote body cannot be placed on the current page due to lack of space, the user agent introduces a forced page break at the start of the line containing the footnote reference, so that both the reference and the footnote body fall on the next page. Note that the user agent must honor <a href=http://dev.w3.org/csswg/css-break/#widows-orphans>widow and orphan</a> settings when doing this, and so may need to insert the page break on an earlier line.</dd>
<dt><dfn class=css-code data-dfn-for=footnote-policy data-dfn-type=value data-export="" id=valuedef-block>block<a class=self-link href=#valuedef-block></a></dfn></dt>
<dd>As with <a href=#footnote-policy-line>line</a>, except a forced page break is introduced before the paragraph that contains the footnote.</dd>
</dl>
<p class=issue id=issue-da883bb8><a class=self-link href=#issue-da883bb8></a>We need an algorithm for laying out footnotes</p>
<p></p>
<h3 class="heading settled heading" data-level=2.9 id=future><span class=secno>2.9 </span><span class=content>
Future directions
</span><a class=self-link href=#future></a></h3>
The next level will include sidenotes, column footnotes, and multiple footnote areas.<p></p>
<h2 class="heading settled heading" data-level=3 id=the-first-page-pseudo-element><span class=secno>3 </span><span class=content>
Selecting Pages
</span><a class=self-link href=#the-first-page-pseudo-element></a></h2>
A paginated document consists of a sequence of pages. <a data-biblio-type=informative data-link-type=biblio href=#css3page title=css3page>[CSS3PAGE]</a> defines <dfn class=css-code data-dfn-type=property data-export="" id=propdef-page-selectors>page selectors<a class=self-link href=#propdef-page-selectors></a></dfn>, which allow the selection of the first page of the document, left and right pages, and blank pages. Here we extend the idea of page selectors to enable the selection of arbitrary document pages.
<h3 class="heading settled heading" data-level=3.1 id=document-page-selectors><span class=secno>3.1 </span><span class=content>
Page Selectors
</span><a class=self-link href=#document-page-selectors></a></h3>
The <span class=css data-link-type=maybe title=nth()>nth()</span> page pseudo-class allows the selection of arbitrary document pages. This pseudo-class takes an argument of the form <a href=http://dev.w3.org/csswg/css-syntax/#anb>An + B</a> as defined in <a data-biblio-type=informative data-link-type=biblio href=#css3syn title=css3syn>[CSS3SYN]</a>. When applied to the default @page rule, <span class=css data-link-type=maybe title=nth()>nth()</span> selects the document page whose index matches the argument.
<pre class=prod>
<dfn class=css-code data-dfn-type=property data-export="" id=propdef-nth>nth()<a class=self-link href=#propdef-nth></a></dfn> = ( An+B [of <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a>]?)
</pre>
<p class=note>
<span class=css data-link-type=maybe title=nth()>nth()</span> is not related to the page counter, which may reset and use various numbering schemes.</p>
<p>When the <span class=css data-link-type=maybe title=nth()>nth()</span> 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.</p>
<div class=example>
<pre>
@page :nth(1)
</pre> This selects the first page of the document. <pre>@page :nth(2n)
</pre> This selects all even document pages.
</div>
<h3 class="heading settled heading" data-level=3.2 id=document-sequence-selectors><span class=secno>3.2 </span><span class=content>
Page groups
</span><a class=self-link href=#document-sequence-selectors></a></h3>
Many paginated documents have a repeating structure, consisting of many chapters, sections, or articles. The first page of each subdivision often requires special treatment, but <a data-biblio-type=informative data-link-type=biblio href=#css3page title=css3page>[CSS3PAGE]</a> doesn’t define a way to select the first page of each chapter (as distinct from the first page of the entire document).
<p>When the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-page-3/#propdef-page title=page>page</a> property is applied to an element that also has a forced break property applied, a <span class=css data-link-type=maybe title="page group">page group</span> is created. The <dfn class=css-code data-dfn-type=property data-export="" id=propdef-page-group>page group<a class=self-link href=#propdef-page-group></a></dfn> is the collection of all pages created by an instance of that element. When a new instance of the element is rendered, a new <span class=css data-link-type=maybe title="page group">page group</span> is started.</p>
<p>A page may be part of several page groups, as a given <span class=css data-link-type=maybe title="page group">page group</span> may have ancestors or descendants that are part of another <span class=css data-link-type=maybe title="page group">page group</span>.</p>
<div class=example>
CSS:
<pre>
div { page: A }
child { page: B }
</pre>
<figure>
<img alt="" src=PageGroups.001.jpg width=480>
<figcaption>A page may be part of several page groups.</figcaption>
</figure>
Note that page 5 can be selected in three ways:
<pre>
@page :nth(5 of A) /* will select 5th page of every &lt;div&gt; */
@page :nth(1 of B) /* will select first page of every &lt;child&gt; */
@page :nth(5) /* will select 5th page of document */
</pre>
</div>
<div class=example>
<p>Consider the following HTML:</p>
<pre>
&lt;div class="chapter"&gt;
&lt;h1&gt;Chapter One&lt;/h1&gt;
&lt;p&gt;some text&lt;/p&gt;
&lt;table class="broadside"&gt;
...
&lt;/table&gt;
...
&lt;/div&gt;
&lt;div class="chapter"&gt;
&lt;h1&gt;Chapter Two&lt;/h1&gt;
&lt;p&gt;some text&lt;/p&gt;
...
&lt;table class="broadside"&gt;
...
&lt;/table&gt;
...
&lt;/div&gt;
</pre>
<p>And CSS:</p>
<pre>
div.Chapter {
page: body;
}
div.broadside {
page: broadside;
}
</pre>
<p>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.</p>
</div>
<h2 class="heading settled heading" data-level=4 id=leaders><span class=secno>4 </span><span class=content>
Leaders
</span><a class=self-link href=#leaders></a></h2>
A leader, sometimes known as a tab leader or a dot leader, is a repeating pattern used to visually connect content across horizontal spaces. They are most commonly used in tables of contents, between titles and page numbers. The <span class=css data-link-type=maybe title=leader()>leader()</span> function, as a value for the content property, is used to create leaders in CSS. This function takes a string (the leader string), which describes the repeating pattern for the leader.
<table class="definition propdef partial"><tr><th>Name:<td><a class=css-code data-link-type=property href=http://dev.w3.org/csswg/css-content-3/#content title=content>content</a><tr><th>New values:<td>leader()<tr><th>Media:<td>paged</table>
<pre class=prod>
<dfn class=css-code data-dfn-type=property data-export="" id=propdef-leader>leader()<a class=self-link href=#propdef-leader></a></dfn> = leader( [dotted | solid | space] | <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#string-value title="<string>">&lt;string&gt;</a>);
</pre>
<p>Three keywords are shorthand values for common strings:
<dl>
<dt id=dotted-leader><a class=self-link href=#dotted-leader></a>dotted</dt>
<dd>leader('. ')</dd>
<dt id=solid-leader><a class=self-link href=#solid-leader></a>solid</dt>
<dd>leader(<a class=property data-link-type=propdesc title=_>_</a>)</dd>
<dt id=space-leader><a class=self-link href=#space-leader></a>space</dt>
<dd>leader(' ')</dd>
<dt id=string-leader><a class=self-link href=#string-leader></a>&lt;string&gt;</dt>
<dd></dd>
</dl>
<div class=example>
<pre>
ol.toc a::after {
content: leader('.') target-counter(attr(href url), page);
}
&lt;h1&gt;Table of Contents&lt;/h1&gt;
&lt;ol class="toc"&gt;
&lt;li&gt;&lt;a href="#chapter1"&gt;Loomings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#chapter2"&gt;The Carpet-Bag&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#chapter3"&gt;The Spouter-Inn&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</pre> This might result in: <pre>Table of Contents
1. Loomings.....................1
2. The Carpet-Bag...............9
3. The Spouter-Inn.............13
</pre>
</div>
<p class=issue id=issue-2f5c8d3f><a class=self-link href=#issue-2f5c8d3f></a>
Do leaders depend on the assumption that the content after the leader is right-aligned (end-aligned)?
</p>
<h3 class="heading settled heading" data-level=4.1 id=rendering-leaders><span class=secno>4.1 </span><span class=content>
Rendering leaders
</span><a class=self-link href=#rendering-leaders></a></h3>
Consider a line which contains the content before the leader (the “before content”), the leader, and the content after the leader (the “after content”). Leaders obey the following rules:
<ol>
<li>The leader string must appear in full at least once. </li>
<li>The leader should be as long as possible</li>
<li>Visible characters in leaders should vertically align with each other when possible.</li>
<li>Line break characters in the leader string must be ignored.</li>
<li>White space in the leader string follows normal CSS rules.</li>
<li>A leader only appears between the start content and the end content.</li>
<li>A leader only appears on a single line, even if the before content and after content are on different lines. </li>
<li>A leader can’t be the only thing on a line. </li>
</ol>
<h4 class="heading settled heading" data-level=4.1.1 id=procedure-leader><span class=secno>4.1.1 </span><span class=content>
Procedure for rendering leaders
</span><a class=self-link href=#procedure-leader></a></h4>
<ol>
<li> Lay out the before content, until reaching the line where the before content ends. <pre>
BBBBBBBBBB
BBB
</pre> </li>
<li> The leader string consists of one or more glyphs, and is thus an inline box. A leader is a row of these boxes, drawn from the end edge to the start edge, where only those boxes not overlaid by the before or after content. On this line, draw the leader string, starting from the end edge, repeating as many times as possible until reaching the start edge. <pre>
BBBBBBBBBB
..........
</pre> </li>
<li> Draw the before and after content on top of the leader. If any part of the before or after content overlaps a glyph in a leader string box, that glyph is not displayed.<pre>
BBBBBBBBBB
BBB....AAA
</pre> </li>
<li> If one full copy of the leader string is not visible: <pre>
BBBBBBB
BBBBBBA
</pre> Insert a line break before the after content, draw the leader on the next line, and draw the end content on top <pre>
BBBBBBB
BBBBBB
......A
</pre> </li>
</ol><p></p>
<figure>
<img alt="drawing leaders" src=leader.001.jpg width=480>
<figcaption>Procedure for drawing leaders</figcaption>
</figure>
<figure>
<img alt="drawing leaders" src=leader.002.jpg width=480>
<figcaption>Procedure for drawing leaders when the content doesn’t fit on a single line</figcaption>
</figure>
<h2 class="heading settled heading" data-level=5 id=cross-references><span class=secno>5 </span><span class=content>
Cross-references
</span><a class=self-link href=#cross-references></a></h2>
Many documents contain internal references:
<ul>
<li> See chapter 7 </li>
<li> in section 4.1 </li>
<li> on page 23 </li>
</ul>
Three new values for the content property are used to automatically create these types of cross-references: <span class=css data-link-type=maybe title=target-counter()>target-counter()</span>, <span class=css data-link-type=maybe title=target-counters()>target-counters()</span>, and <span class=css data-link-type=maybe title=target-text()>target-text()</span>. Each of these displays information obtained from the target end of a link.
<h3 class="heading settled heading" data-level=5.1 id=target-counter><span class=secno>5.1 </span><span class=content>
The <span class=css data-link-type=maybe title=target-counter()>target-counter()</span> function
</span><a class=self-link href=#target-counter></a></h3>
The <span class=css data-link-type=maybe title=target-counter()>target-counter()</span> function retrieves the value of the innermost counter with a given name. The required arguments are the url of the target and the name of the counter. An optional counter-style argument can be used to format the result.
<p class=note>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.</p>
<pre class=prod>
<dfn class=css-code data-dfn-type=property data-export="" id=propdef-target-counter>target-counter()<a class=self-link href=#propdef-target-counter></a></dfn> = target-counter( <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#url-value title="<url>">&lt;url&gt;</a> , <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a> [ , <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-counter-styles-3/#typedef-counter-style title="<counter-style>">&lt;counter-style&gt;</a> ]? )
</pre>
<div class=example>
HTML:
<pre>
…which will be discussed on page &lt;a href="#chapter4_sec2"&gt;000&lt;/a&gt;.
</pre>
<p>CSS:
<pre>
a::after { content: target-counter(attr(href url), page) }
<p>Result:
<pre>
…which will be discussed on page 137.
</pre></pre></div>
<div class=example>
Page numbers in tables of contents can be generated automatically:
<p>HTML:
<pre>
&lt;nav&gt;
&lt;ol&gt;
&lt;li class="frontmatter"&gt;&lt;a href="#pref_01"&gt;Preface&lt;/a&gt;&lt;/li&gt;
&lt;li class="frontmatter"&gt;&lt;a href="#intr_01"&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li class="bodymatter"&gt;&lt;a href="#chap_01"&gt;Chapter One&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/nav&gt;
<p>CSS:
<pre>
.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) }
<p>Result:
<pre>
Preface.............vii
Introduction.........xi
Chapter One...........1
</pre></pre></pre></div>
<h3 class="heading settled heading" data-level=5.2 id=target-counters><span class=secno>5.2 </span><span class=content>
The <span class=css data-link-type=maybe title=target-counters()>target-counters()</span> function
</span><a class=self-link href=#target-counters></a></h3>
This functions fetches the value of all counters of a given name from the end of a link, and formats them by inserting a given string between the value of each nested counter.
<pre class=prod>
<dfn class=css-code data-dfn-type=property data-export="" id=propdef-target-counters>target-counters()<a class=self-link href=#propdef-target-counters></a></dfn> = target-counter( <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#url-value title="<url>">&lt;url&gt;</a> , <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>">&lt;custom-ident&gt;</a> , <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#string-value title="<string>">&lt;string&gt;</a> [ , <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-counter-styles-3/#typedef-counter-style title="<counter-style>">&lt;counter-style&gt;</a> ]? )
</pre>
<div class=example>
<pre>
I have not found a compelling example for target-counters() yet.
</pre>
</div>
<h3 class="heading settled heading" data-level=5.3 id=target-text><span class=secno>5.3 </span><span class=content>
target-text
</span><a class=self-link href=#target-text></a></h3>
The <span class=css data-link-type=maybe title=target-text()>target-text()</span> function retrieves the text value of the element referred to by the URL. An optional second argument specifies what content is retrieved, using the same values as the <a class=property data-link-type=propdesc href=#propdef-string-set title=string-set>string-set</a> property above.
<pre class=prod>
<dfn class=css-code data-dfn-type=property data-export="" id=target-text-function>target-text()<a class=self-link href=#target-text-function></a></dfn> = target-counter( <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#url-value title="<url>">&lt;url&gt;</a> [ , [ content | before | after | first-letter] ]? )
</pre>
<p class=issue id=issue-a82075c9><a class=self-link href=#issue-a82075c9></a>A simpler syntax has been proposed by fantasai: http://lists.w3.org/Archives/Public/www-style/2012Feb/0745.html</p>
<div class=example>
<pre>
…which will be discussed &lt;a href="#chapter_h1_1"&gt;later&lt;/a&gt;.
a::after { content: ", in the chapter entitled " target-text(attr(href url)) }
</pre> Result: …which will be discussed later, in the chapter entitled Loomings. </div>
<h2 class="heading settled heading" data-level=6 id=bookmarks><span class=secno>6 </span><span class=content>