-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathpage.src
More file actions
552 lines (440 loc) · 19.3 KB
/
page.src
File metadata and controls
552 lines (440 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
4
8000
44
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<!-- $Id: page.src,v 1.14 1997-11-27 03:27:48 ian Exp $ -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>Paged media</TITLE>
<LINK rel="next" href="colors.html">
<LINK rel="previous" href="flowobj2.html">
<LINK rel="STYLESHEET" href="style/default.css" type="text/css">
</HEAD>
<BODY>
<H1 align="center"><a name="the-page">Paged media</a></H1>
<H2>Introduction to paged media</H2>
<P>Paged media -- paper, transparencies, computer screens that display
pages, etc. -- differ from <a
href="./media.html#continuous-media">continuous media</a> in that
formatting algorithms for pages must account for <a
href="./#page-breaks">page breaks.</a>
<P>To handle page breaks, CSS2 extends two previous models:
<ol>
<li>The <span class="index-def" title="page box"><dfn>page
box</dfn></span> extends the <a href="flowobj.html#box-model">box model</a>
to allow authors to specify the size of a page, its margins, etc.
<li>The <span class="index-def" title="page model"><dfn>page
model</dfn></span> extends the <a
href="flowobj.html#flow-model">visual flow model</a> to
account for <a href="#page-breaks">page breaks.</a>
In the page model, the <a href="media.html#canvas">canvas</a>
is the page box.
</ol>
<P>The <a name="page-model">page model</a> specifies how a document is
formatted within a rectangular area -- the <a name="page-box">page
box</a> -- that has a finite width and height. The <a
href="#page-boxes">page box</a> is an abstract rectangle that does not
necessarily correspond to the <span class="index-def" title="sheet">
<dfn>sheet</dfn></span> where the document will ultimately be rendered
(paper, transparency, screen, etc.).
<P>The CSS page model specifies formatting in the page box, but it is
the user agent's responsibility to transfer the page box to the
sheet. Some transfer possibilities include:
<ul>
<li>Transferring one page box to one sheet (e.g., single-sided printing).
<li>Transferring two page boxes to both sides of the same sheet (e.g.,
double-sided printing).
<li>Transferring N (small) page boxes to one sheet (called <span
class="index-def" title="n-up"><em>n-up</em></span>
printing).
<li>Transferring one (large) page box to N x M sheets (called "tiling").
<li>Printing signatures (a group of pages
printed on a sheet, which, when folded and trimmed like a book, appear in their
proper sequence).
<li>Printing one document to several output trays.
<li>Transferring to a file.
</ul>
<P>This document does not specify how user agents transfer page boxes
to sheets. It does allow users to provide the user agent (often
through a dialog box) with information about the size of the sheet and
the orientation of the transfer (see the <span
class="propinst-size">'size'</span> property).
<H2><a name="page-breaks">Page breaks</a></H2>
<P>The following sections explain page formatting in CSS2. Four
properties indicate where the user agent may or should break pages,
and on what page (left or right) the subsequent content should resume.
Each page break ends the current page box and begins the next.
<P>These properties have been designed to support the <span
class="index-def" title="print medium|medium, print">PRINT</span>
me
10000
dium, but can also be applied to other <a
href="media.html#media-types">paged media</a>, for example <span
class="index-def" title="projector medium|medium,
projector">PROJECTOR</span> medium.
<h3>Page break properties: <span
class="propinst-page-break-before">'page-break-before'</span>,
<span class="propinst-page-break-after">'page-break-after'</span>,
<span class="propinst-orphans">'orphans'</span>, and
<span class="propinst-widows">'widows'</span>
</h3>
<!-- #include src=properties/page-break-before.srb -->
<!-- #include src=properties/page-break-after.srb -->
<P>Values for these properties have the following meanings:
<dl>
<dt><strong>auto</strong></dt>
<dd>Neither force nor forbid a page break before (resp., after) the element
<dt><strong>always</strong></dt>
<dd>Always force a page break before (resp., after) the element </dd>
<dt><strong>avoid</strong></dt>
<dd>Avoid a page break before (resp., after) the element.
<dt><strong>left</strong></dt>
<dd>Force one or two page breaks before (resp., after) the element
so that the next page to be formatted is a left page.</dd>
<dt><strong>right</strong></dt>
<dd>Force one or two page breaks before (resp., after) the element
so that the next page to be formatted is a right page.</dd>
</dl>
<P>When both properties apply, 'always', 'left', and 'right' take
precedence over 'avoid'. See the section on <a
href="#allowed-page-breaks">allowed page breaks</a> for the exact
rules on how these values force or suppress a page break.
<!-- #include src=properties/orphans.srb -->
<!-- #include src=properties/widows.srb -->
<P>These properties specify the minimum number of lines of a paragraph
that must be left at the bottom (<span
class="propinst-orphans">'orphans'</span>) and top (<span
class="propinst-widows">'widows'</span>) of a page.
<h3><a name="allowed-page-breaks">Allowed page breaks</a></h3>
<p>In the normal flow, page breaks can occur at the following places:
<ol>
<li>
In the vertical margin between block-level elements. When a page
break occurs here, the margin disappears (becomes zero).
<li>
Between lines inside a block-level element.
</ol>
<p>These breaks are subject to the following rules:
<ol style="list-style-type: upper-alpha">
<li>Breaking at (1) is only allowed if the <span
class="propinst-break-after">'break-after'</span> and <span
class="propinst-break-before">'break-before'</span> properties of all
the elements that meet at this margin allow it, which is when at least
one of them has the value 'always', 'left', or 'right', or when all of them are
'auto'.
<li>
Breaking at (2) is only allowed if the number of lines between the
break and the start of the block is <span
class="propinst-orphans">'orphans'</span> or more, and the number of
lines between the break and the end of the block is <span
class="propinst-widows">'widows'</span> or more.
</ol>
<p>There is an exception to both rules:
<ol start="3" style="list-style-type: upper-alpha">
<li>
Breaking at (1) and (2) is also allowed if, between the last page break
and the next one that would be allowed under (A) and (B), there is so
much content that it can't fit on a page.
</ol>
<P>Page breaks cannot occur inside positioned elements.
<h3>Forced page breaks</h3>
<p>A page break <em>must</em> occur at (1) if, among the <span
class="propinst-break-after">'break-after'</span> and <span
class="propinst-break-before">'break-before'</span> properties of all
the elements that meet at this margin, there is at least one with the value
'always', 'left', or 'right'.
<h3>"Best" page breaks</h3>
<p>CSS does <em>not</em> define which of the page breaks allowed by
(A), (B), or (C) should be used. In particular, CSS does not forbid a
UA from breaking at every possible break point, or not to break at all. But
CSS does recommend that UAs observe the following heuristics (while
recognizing that they are sometimes contradictory):
<ul>
<li>
Break as few times as possible.
<li>
Make all pages that don't end with a forced break appear to have about
the same height.
<li>
Avoid breaking inside a block that has a border.
<li>
Avoid breaking inside a table.
<li>
Avoid breaking inside a floating element
</ul>
<div class="example"><P>
Suppose, for example, that <span
class="propinst-orphans">'orphans'</span>=4, <span
class="propinst-widows">'widows'</span>=2, and
there are 20 lines available at the bottom of the current page:
<ul>
<li>If a paragraph at the end of the current page contains 20 lines or fewer,
it should be placed on the current page.
<li>If the paragraph contains 21 - 22 lines, the second part of the
paragraph must not violate the <span
class="propinst-widows">'widows'</span> constraint, and so the
second part must contain exactly two lines
<li>If the paragraph contains 23 lines or more, the first part should
contain 20 lines and the second part the remaining lines.
</ul>
<P>Now suppose that <span class="propinst-orphans">'orphans'</span>=10,
<span class="propinst-widows">'widows'</span>=20,
and there are 8 lines available at the bottom of the current page:
<ul>
<li>If a paragraph at the end of the current page contains 8 lines or
less, it should be placed on the current page.
<li>If the paragraph contains 9 or more lines, it cannot be split
(that would violate the orphan constraint), so it should move
as a block to the next page.
</ul>
</div>
<H2><a name="page-boxes">Page boxes</a>: the @page rule</H2>
<P>CSS2 allows authors to specify the dimensions of the page box, the
margins, and several other properties relative to each page. However,
since some document languages (e.g., HTML) do not define elements that
represent "the page", these properties are specified for an entire
document via the <span class="index-def" title="@page">@page</span>
rule.
<div class="example"><P>
For example, the following @page rule sets the margins of the page to 2cm.
<pre>
@page { margin: 2cm }
</pre>
</div>
<p>Declarations inside the curly braces of the @page rule apply to
every page of a document. These declarations are said to be in the
<span class="index-def" title="page-context"><em>page
context</em></span>, and they describe the <a href="#page-box">page
box</a> into which the elements of the document are flowed according
to the <a href="#page-model">page model.</a>
<p>The page context allows the <span
class="propinst-size">'size'</span> property to set the size of the
page box and the <span class="propinst-marks">'marks'</span> property
to set crop and cross marks.
<h3><a name="page-margins">Page margins</a></h3>
<P>In addition, the following page margin properties, defined for the
<a href="flowobj.html#box-model">box</a> that surrounds each element,
apply within the page context:
<ul>
<li><span class="propinst-margin-top">'margin-top'</span>
<li><span class="propinst-margin-right">'margin-right'</span>
<li><span class="propinst-margin-bottom">'margin-bottom'</span>
<li><span class="propinst-margin-left">'margin-left'</span>
<li><span class="propinst-margin">'margin'</span>
</ul>
<P>The diagram below shows the relationships between the sheet, page
box, and page margins:</P>
<img src="./images/page-info.gif" alt="Illustration of sheet, page box, and margin.">
<p>Note that the page margins are included in the page box.
<div class="note"><P>
<em><strong>Note.</strong> In the future, <a
href="./flowobj2.html#border-properties">border properties</a> and <a
href="./flowobj2.html#padding-properties">padding properties</a> may
also be allowed in the page context.
</em>
</div>
<P>The CSS2 rules for <a
href="flowobj2.html#collapsing-margins">collapsing vertical
margins</a> apply to page margins as well. For example, the margin of
the first element box on a page will collapse with the page margin.
<p>The page context has no notion of fonts, so 'em' and 'ex' units are
not allowed. Percentage values on the margin properties are relative
to the dimensions of the page box. All other units associated with
the respective CSS2 properties are allowed.
<P>Due to negative margin values (either on the page box or on
elements) or <a href="flowobj.html#absolute-positioning">absolute
positioning</a> content may end up outside the page box, but this
content may be cut -- by the user agent, the printer, or ultimately
the paper cutter.
<h3>Page size: the <span class="propinst-size">'size'</span> property</h3>
<!-- #include src=properties/size.srb -->
<P>This property specifies the size and orientation of a page box.
<P>The size of a page box may either be "absolute" (fixed size) or
"relative" (scalable, i.e., fitting available sheet sizes). Relative
page boxes allow user agents to scale a document and make optimal use
of the target size. Absolute page boxes ensure precise formatting when
that is the author's prerogative.
<P>Three values for the <span class="propinst-size">'size'</span>
property create a relative page box:
<DL>
<DT>auto
<DD>The page box will be set to the size and orientation of the
target sheet. This is the initial value of the property.
<div class="example"><P>
<pre>
@page {
size: auto;
margin: 10%;
}
</pre>
<p>In the above example, the outer edges of the page box will align
with the target. (Since 'auto' is the initial value on <span
class="propinst-size">'size'</span>, it is normally not necessary to
set this value.) The percentage value on the <span
class="propinst-margin">'margin'</span> property is relative to the
target size so if the target is 21.0cm x 29.7cm (i.e., A4), the
margins are 2.10cm and 2.97cm.
</div>
<DT>landscape
<DD>The page box will have the same size as the target, and the normal
direction of print occurs across the largest dimension of the target.
Thus, the target orientation will be ignored.
<DT>portrait
<DD>the page box will have the same size as the target, and the normal
direction of print occurs across the shortest dimension of the target.
Thus, the target orientation will be ignored.
</DL>
<P>Explicit length values for the <span
class="propinst-size">'size'</span> property create an absolute page
box. If only one length value is specified, it sets both the width and
height of the page box (i.e., the box is a square). Since the page box
has no "parent", percentage values are not allowed on the <span
class="propinst-size">'size'</span> property.
<div class="example"><P>
For example:
<PRE>
@page {
size: 8.5in 11in; /* width height */
}
</PRE>
<P>The above example set the width of the page box to be 8.5in and the
height to be 11in. The page box in this example requires a target
size of 8.5"x11" or bigger to be printed.
</div>
<P>User agents may allow users to control the transfer of the page
box to the sheet (e.g., rotating an absolute page box that's
being printed).
<h4>Rendering page boxes that do not fit a target sheet</h4>
<P>If page box does not fit the target sheet dimensions, the
user agent may choose to:
<UL>
<LI>Rotate the page box 90° if this will make the page box fit.
<LI>Scale the page to fit the target.
</UL>
<P>The user agent should consult the user before performing these
operations.
<P>When the page box is smaller than the target size, the user agent
is free to place the page box anywhere on the sheet. However, it is
recommended that the page box be centered on the sheet since this will
align double-sided pages and avoid accidental loss of information that
is printed near the edge of the sheet.
<div class="note"><P>
<em><strong>Note.</strong>
Typically, 8.5"x11" sheet size will be available in North
America, while printers in other parts of the world are more likely to
have the A4 sheet size available.
</em>
</div>
<h3>Crop marks: the <span class="propinst-marks">'marks'</span>
property</h3>
<!-- #include src=properties/marks.srb -->
<p>In high-quality printing, various marks are often added outside the
page box. <span class="index-def" title="crop marks"><EM>Crop
marks</EM></span> indicate where the page should be cut and <span
class="index-def" title="cross marks"><EM>cross marks</em></span>
(also known as register marks or registration marks) are used to align
sheets. This property describes what marks should be printed on the
page outside the outer edges of the page box.
<P>Marks are only visible on absolute page boxes. In relative page
boxes, the page box will be aligned with the target and the marks
will be outside the printable area.
<P>The size, style, and position of cross marks depends on the user
agent.
<h3>Left and right pages</H3>
<P>When printing double-sided documents, the page boxes on left and
right pages should be different. This can be expressed through two CSS
pseudo-classes that may be defined in the page context.
<P>All pages are automatically classified by user agents into either
the <span class="index-def" title=":left|pseudo-class,
:left">:left</span> or <span class="index-def"
title=":right|pseudo-class, :right">:right</span> pseudo-class.
<div class="example"><P>
<PRE>
@page :left {
margin-left: 4cm;
margin-right: 3cm;
}
@page :right {
margin-left: 3cm;
margin-right: 4cm;
}
</PRE>
</div>
<P>If different declarations have been given for left and right pages,
the user agent must honor these declarations even if the user agent
does not transfer the page boxes to left and right sheets (e.g., a
printer that only prints single-sided).
<P>Whether the first page of a document is :left or :right depends on
the major writing direction of the document and is outside the scope
of this document. However, to force a :left or :right first page,
authors may insert a page break before the element at the top of the
document tree (e.g., the HTML element in HTML).
<div class="note"><P>
<em><strong>Note.</strong>
Adding declarations to the :left or :right pseudo-class does not
influence whether the document comes out of the printer double- or
single-sided (which is outside the scope of this specification).
</em>
</div>
<div class="note"><P>
<em><strong>Note.</strong>
Future versions of CSS may include other page pseudo-classes (e.g.,
:first).
</em>
</div>
<h3>Content outside the page box</h3>
<P>When formatting content in the page model, some content may end up
outside the page box. For example, an element with 'white-space: pre'
may be wider than the page box. Also, when elements are positioned
outside the <a href="flowobj.html#flow-model">flow model</a>, they
may end up in inconvenient locations. For example, images may be
placed on the edge of the page box or 100,000 inches below the page
box.
<P>A specification for the exact formatting of such elements lies
outside the scope of this document. However, we recommend that authors
and user agents observe the following general principles concerning
content outside the page box:
<ul>
<li>Content should be formatted slightly beyond the page box to allow
pages to "bleed".
<li>User agents should avoid printing large numbers of blank pages to
honor positioning of elements. Note, however, that printing small
numbers of blank pages may be necessary to honor the 'left' and
'right' values for <span
class="propinst-page-break-before">'page-break-before'</span> and
<span class="propinst-page-break-after">'page-break-after'</span>.
<li>Authors should not position elements in inconvenient locations
as a means to avoid printing them. Authors should use the
<span class="propinst-display">'display'</span> or
<span class="propinst-visibility">'visibility'</span> properties
for this purpose.
<LI>User agents may handle elements positioned outside the page box in
several ways, including discarding them or printing them at the end of
the document.
</ul>
<h2>Cascading in the page context</H2>
<P>Declarations in the page context cascade just like normal CSS2
declarations.
<div class="example"><P>
Consider the following example:
<PRE>
@page {
margin-left: 3cm;
}
@page :left {
margin-left: 4cm;
}
</PRE>
<P>Due to the higher specificity of the pseudo-class selector (see the
section on <a href="cascade.html#cascading-order">cascading order</a>
for details), the left margin on left pages will be '4cm' and all
other pages (i.e., the right pages) will have a left margin of '3cm'.
</div>
</body>
</html>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-declaration:"~/SGML/HTML4.decl"
sgml-default-doctype-name:"html"
sgml-minimize-attributes:t
sgml-nofill-elements:("pre" "style" "br")
sgml-live-element-indicator:t
End:
-->