css3-page/Overview.src.html

Mon, 11 Feb 2013 14:15:36 -0800

author
Simon Sapin <simon.sapin@exyr.org>
date
Mon, 11 Feb 2013 14:15:36 -0800
changeset 7435
2fa0f76c392e
parent 7434
bdbe85bfb65b
child 7436
6ded58aacc4c
permissions
-rwxr-xr-x

[css3-page][css3-gcpm] Move :blank to css3-page, per WG resolution

CSSWG resolution:
http://lists.w3.org/Archives/Public/www-style/2012Nov/0250.html

fantasai@213 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
fantasai@213 2 <html lang="en">
fantasai@213 3 <head>
fantasai@213 4 <title>
fantasai@215 5 CSS Paged Media Module Level 3
fantasai@213 6 </title>
fantasai@213 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
fantasai@213 8 <link href="../default.css" rel="stylesheet" type="text/css">
fantasai@213 9 <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-ED.css">
fantasai@215 10 <style type="text/css">
fantasai@215 11 .keyword { font-weight:bold }
fantasai@213 12 .equation { padding: 2% }
fantasai@213 13 table.equation {text-align:center}
fantasai@213 14 td, th { vertical-align: top }
fantasai@213 15 pre { font-size: 1em; }
simon@6956 16
simon@6956 17 #margin-values { border-collapse: collapse; }
simon@6956 18 #margin-values td,
simon@6956 19 #margin-values th
simon@6956 20 {
simon@6956 21 padding: 0.2em;
fantasai@213 22 border: thin solid black;
fantasai@213 23 }
fantasai@213 24
fantasai@213 25 .property-list
fantasai@213 26 {
fantasai@213 27 border: 1px solid black;
fantasai@213 28 padding: .2em;
fantasai@213 29 margin-top: 2em;
fantasai@213 30 }
simon@6956 31
fantasai@213 32 .property-list td
fantasai@213 33 {
fantasai@213 34 border: 1px solid black;
fantasai@213 35 padding: .1em;
fantasai@213 36 }
fantasai@213 37
simon@6956 38 .editorial
simon@6956 39 {
simon@6956 40 display: block;
fantasai@213 41 font-family: arial, helvetica, sans-serif;
fantasai@213 42 font-size: 80%;
simon@6956 43 margin-left: .5in;
simon@6956 44 margin-right: 1in ;
fantasai@213 45 padding: 0.125in;
fantasai@213 46 background: #FFFFDD ;
fantasai@213 47 }
simon@6956 48
fantasai@213 49 .editorial:after { content: "Ed."}
simon@6956 50 .RFC2119
simon@6956 51 {
simon@6956 52 text-transform: lowercase;
simon@6956 53 font-style: italic
fantasai@213 54 }
simon@6956 55
simon@6956 56 em em.RFC2119
fantasai@213 57 {
simon@6956 58 text-transform: lowercase;
simon@6956 59 font-style: normal
simon@6956 60 }
simon@6956 61
simon@6956 62 table.page-sizes
simon@6956 63 {
simon@6956 64 border: thin solid;
fantasai@213 65 margin-top: 1.5em;
fantasai@213 66 }
simon@6956 67 table.page-sizes td
simon@6956 68 {
simon@6956 69 border: thin solid;
fantasai@213 70 padding: .5em;
fantasai@213 71 }
simon@6956 72 table.page-sizes th
simon@6956 73 {
simon@6956 74 border: thin solid;
simon@6956 75 padding: .5em;
fantasai@213 76 background: #ffffaa;
fantasai@213 77 }
fantasai@213 78
fantasai@213 79 </style>
fantasai@213 80 </head>
fantasai@213 81 <body>
fantasai@213 82 <div>
fantasai@213 83 <div class="head">
fantasai@213 84 <!--logo-->
fantasai@213 85 <h1>CSS Paged Media Module Level 3</h1>
fantasai@213 86 <h2 class="no-num no-toc" id="w3c-working">[LONGSTATUS] [DATE]</h2>
fantasai@213 87 <dl>
fantasai@213 88 <dt>This version:</dt> <dd><a href="http://dev.w3.org/csswg/css3-page/">http://dev.w3.org/csswg/css3-page/</a></dd>
fantasai@213 89 <!-- <dd><a href="[VERSION]">http://www.w3.org/TR/[YEAR]/WD-[SHORTNAME]-[CDATE]</a></dd> -->
fantasai@213 90 <dt>Latest version:</dt> <dd><a href="http://www.w3.org/TR/css3-page">http://www.w3.org/TR/css3-page</a></dd>
fantasai@213 91 <dt>Previous version:</dt> <dd><a href="http://www.w3.org/TR/2004/CR-css3-page-20040225/">http://www.w3.org/TR/2004/CR-css3-page-20040225/</a></dd>
fantasai@213 92 <dt>Editors:</dt> <dd>Melinda Grant, Hewlett-Packard</dd>
fantasai@213 93 <dd>H&aring;kon Wium Lie, Opera Software</dd>
fantasai@213 94 <dd>Elika J. Etemad, Hewlett-Packard</dd>
simon@7067 95 <dd>Simon Sapin, Kozea</dd>
fantasai@213 96 </dl>
fantasai@213 97
fantasai@213 98 <!--copyright-->
fantasai@213 99
fantasai@213 100 </div>
fantasai@213 101 <hr title="Separator for header">
fantasai@213 102
fantasai@213 103 <h2 class="no-num no-toc" id="abstract">Abstract</h2>
fantasai@213 104
fantasai@213 105 <p>This module describes the page model that partitions a flow into pages. It
fantasai@5976 106 builds on the <a href="http://www.w3.org/TR/CSS21/box.html">Box model module</a> and introduces
fantasai@213 107 and defines the page model and paged media. It adds functionality for
fantasai@213 108 pagination, page margins, page size and orientation, headers and footers,
fantasai@213 109 widows and orphans, and image orientation. Finally it extends generated content
fantasai@213 110 to enable page numbering and running headers / footers.</p>
fantasai@213 111
fantasai@213 112 <!-- "Status of this document" -->
fantasai@213 113
fantasai@213 114 <h2 class="no-num no-toc" id="status">Status of this Document</h2>
fantasai@213 115
fantasai@213 116 <!--status-->
fantasai@213 117
fantasai@213 118 <p>This document contains the <abbr title="Cascading Style Sheets">CSS3</abbr>
fantasai@213 119 Paged Media Module W3C Last Call <a href="/2005/10/Process-20051014/tr.html#RecsWD">Working Draft</a> of [DATE]. The
fantasai@213 120 Last Call period ends on <span class="fudge">TBD</span>.</p>
fantasai@213 121
fantasai@2094 122 <p>Relative to the previous Last Call Working Draft, this version has dropped
fantasai@2094 123 the formerly named 'fit' and 'fit-position' properties; they are
fantasai@2094 124 renamed to 'object-fit' and 'object-position', redefined to enable additional
fantasai@2094 125 use cases, and moved to the
fantasai@2094 126 <a href="http://www.w3.org/TR/css3-images/">CSS3 Image Values and Replaced Content module</a>.
simon@7289 127 The page-page-margin box sizing algorithm has been reworded to be a bit simpler,
fantasai@2094 128 and many miscellaneous clarifications and editorial improvements have
fantasai@213 129 been incorporated.</p>
fantasai@213 130
fantasai@1101 131 <p>Features at-risk (may be removed if they lack implementor interest):</p>
fantasai@583 132 <ul>
fantasai@1101 133 <li>comma-separated page selectors
fantasai@583 134 </ul>
fantasai@213 135
fantasai@2094 136 <p>Expected next revision to this document is another LCWD, due to the
simon@7289 137 substantive changes to page-margin box sizing and other areas that are now
fantasai@2094 138 specified with more precision.</p>
fantasai@213 139
fantasai@213 140 <p>The <a href="lc2_issues.htm">Disposition of Comments</a>
fantasai@213 141 document contains the current issues list and responses to input received
fantasai@213 142 during this Last Call period.</p>
fantasai@213 143
fantasai@213 144 <h2 class="no-num no-toc" id="contents">Table of Contents</h2><!--begin-toc-->
fantasai@213 145 <!--end-toc-->
fantasai@213 146 <!-- "Introduction" -->
fantasai@213 147 <h2 id="intro">Introduction</h2>
fantasai@213 148
fantasai@213 149 <p>Paged media (e.g., paper, transparencies, photo album pages, pages
fantasai@213 150 displayed on computer screens as printed output simulations) differ from
fantasai@5976 151 <a href="http://www.w3.org/TR/CSS2/media.html#continuous-media-group">continuous media</a>
fantasai@213 152 in that the content of the document is split into one or more discrete
fantasai@213 153 static display surfaces. To handle pages, CSS3 Paged Media describes how:</p>
fantasai@213 154
fantasai@213 155 <ul>
fantasai@213 156 <li><a href="#page-breaks">page breaks</a> are created and avoided;</li>
fantasai@213 157 <li>the page properties such as size, orientation, margins, border, and
fantasai@213 158 padding are specified;</li>
fantasai@213 159 <li>headers and footers are established within the page margins;</li>
fantasai@213 160 <li>content such as page counters are placed in the headers and footers; and</li>
fantasai@213 161 <li>orphans and widows can be controlled.</li>
fantasai@213 162 </ul>
fantasai@213 163
fantasai@213 164 <p>This module defines a <a href="#page-model">page model</a> that specifies how a
fantasai@552 165 document is formatted within a rectangular area, called the
fantasai@552 166 <a href="#page-box-page-rule">page box</a>, that has finite width and height.
fantasai@522 167
fantasai@527 168 <p>Although CSS3 does not specify how user agents transfer page boxes to sheets,
fantasai@527 169 it does include certain mechanisms for telling user agents about the intended
fantasai@527 170 page sheet <a href="#page-size">size and orientation</a>. In the general case,
fantasai@527 171 CSS3 assumes that one page box will be transferred to one surface of similar
fantasai@527 172 size.</p>
fantasai@522 173
fantasai@1052 174 <p>All properties defined in this specification also accept the
fantasai@1052 175 <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
fantasai@1052 176 keyword as their value, but for readability it has not been listed explicitly.
fantasai@522 177
fantasai@527 178 <h2 id="conformance">Conformance</h2>
fantasai@522 179
fantasai@685 180 <p>All of the text in this specification is normative except sections
fantasai@685 181 explicitly marked as non-normative, examples, and notes. The keywords
fantasai@685 182 "<em class="RFC2119">MUST</em>", "<em class="RFC2119">SHALL</em>",
fantasai@527 183 "<em class="RFC2119">MUST NOT</em>", "<em class="RFC2119">SHALL NOT</em>",
fantasai@527 184 "<em class="RFC2119">REQUIRED</em>", "<em class="RFC2119">SHOULD</em>",
fantasai@527 185 "<em class="RFC2119">SHOULD NOT</em>", "<em class="RFC2119">RECOMMENDED</em>",
fantasai@527 186 "<em class="RFC2119">MAY</em>", and "<em class="RFC2119">OPTIONAL</em>" when
fantasai@527 187 used in this document are to be interpreted as described in <cite>RFC
fantasai@527 188 2119</cite> [[!RFC2119]]. However, for readability, these words do not appear
fantasai@685 189 in all uppercase letters in this specification.</p>
fantasai@522 190
fantasai@527 191 <p>Examples in this specification are introduced with the words "for example"
fantasai@527 192 or are set apart from the normative text with <code>class="example"</code>,
fantasai@527 193 like this:
fantasai@522 194
fantasai@527 195 <div class="example">
fantasai@527 196 <p>This is an example of an informative example.</p>
fantasai@527 197 </div>
fantasai@523 198
fantasai@527 199 <p>Informative notes begin with the word "Note" and are set apart from the
fantasai@527 200 normative text with <code>class="note"</code>, like this:
fantasai@523 201
fantasai@527 202 <p class="note">Note, this is an informative note.</p>
fantasai@527 203
fantasai@564 204 <h2 id="page-terms">Page Terminology</h2>
fantasai@213 205
fantasai@213 206 <p>The following terminology and accompanying diagrams help to describe the
fantasai@523 207 page model:</p>
fantasai@213 208
fantasai@213 209 <dl>
fantasai@213 210 <dt id="page-sheet">Page sheet</dt>
fantasai@213 211 <dd><img src="PageSheet.png" style="float: right;" alt="The corner of a page sheet with the non-printable area at the edge and printable area inside it"
fantasai@213 212 height="148" width="194">The page sheet is one surface of the physical
fantasai@213 213 medium. The illustration to the right shows a representation of the upper-left
fantasai@213 214 corner of a page sheet.</dd>
fantasai@523 215
fantasai@213 216 <dt id="printable-area">Printable and non-printable areas</dt>
fantasai@213 217 <dd>The non-printable area is the area of a page sheet that a physical device such
fantasai@213 218 as a printer is not capable of marking reliably, usually due to the printer's
fantasai@213 219 paper handling mechanism. This value is printer dependent and is usually a
fantasai@213 220 small region along each edge of the page sheet. The printable area is the area
fantasai@213 221 of page sheet that a printer <em>is</em> capable of marking reliably. The size
fantasai@213 222 of the printable area is the size of the page sheet reduced by the size of the
fantasai@213 223 non-printable area. A user agent may not know the dimensions of this area for a
fantasai@213 224 particular printing device; but when its dimensions are known, user agents
fantasai@213 225 <em class="RFC2119">MAY</em> adjust the formatting of the document so that
fantasai@213 226 content falls within the printable area. How this adjustment is accomplished is
fantasai@5987 227 device dependent within the constraints expressed in the sections
fantasai@5987 228 <a href="#renderingpages">Rendering page boxes that do not fit a page sheet</a> and
fantasai@213 229 <a href="#content-outside-box">Content outside the page box</a>.</dd>
fantasai@523 230
fantasai@523 231 <dt id="page-orientation">Page Orientation</dt>
fantasai@523 232 <dd>The page orientation is defined by comparing the length of the edges of a
fantasai@523 233 <a href="#page-box">page box</a>. The page box is a rectangle with two
fantasai@523 234 perpendicular edges called the long edge and the short edge. The length of the
fantasai@523 235 long edge is always greater than or equal to the length of the short edge. When
fantasai@523 236 the page box is square, the two edges are of the same length and either can be
fantasai@523 237 used as the long edge with the other being the short edge. This specification
fantasai@523 238 defines page orientations of 'portrait' and 'landscape'.</dd>
fantasai@523 239
fantasai@523 240 <dt id="portrait">Portrait Orientation</dt>
fantasai@523 241 <dd>A portrait page's height is greater than or equal to its width. Horizontal
fantasai@523 242 elements are parallel to the short edge and vertical elements to the long edge.</dd>
fantasai@523 243
fantasai@523 244 <dt id="landscape">Landscape Orientation</dt>
fantasai@523 245 <dd>A landscape page's width is greater than or equal to its height. Horizontal
fantasai@1136 246 elements are parallel to the long edge and vertical elements to the short edge.
fantasai@1136 247 <span class="note">Note that CSS3 makes no distinction between landscape and
fantasai@1136 248 reverse-landscape orientations. However, future versions of CSS may do so.
fantasai@1136 249 UAs should consider, when formatting for duplexed printing, the binding edge,
fantasai@1136 250 page progression, and ease of reading when choosing between landscape and
fantasai@1136 251 reverse-landscape renderings.</span>
fantasai@1136 252 </dd>
fantasai@523 253
fantasai@523 254 <dt id="duplex-printing">Duplex Printing</dt>
fantasai@523 255 <dd>Duplex printing prints one page box per side of a page sheet and uses both
fantasai@523 256 sides of the page sheet. This module provides no ability to specify whether a
fantasai@523 257 document is duplex printed, but the concept of left and right pages is based on
fantasai@523 258 the assumption that the document is duplex printed, regardless of whether or
fantasai@523 259 not it actually is.</dd>
fantasai@523 260
fantasai@523 261 <dt id="binding-edge">Binding Edge</dt>
fantasai@523 262 <dd>The binding edge is the edge of the page box that is toward the binding if the
fantasai@523 263 material is bound. The binding edge often has a larger margin than the opposite
fantasai@523 264 edge to provide for the space used by the binding. The binding edge can be any
fantasai@523 265 of the four edges. However, page sheets are customarily bound so that the
fantasai@523 266 binding edge of page boxes with portrait orientation is vertical. This module
fantasai@523 267 provides no method to specify the binding edge. In duplex printing, the binding
fantasai@523 268 edge is on opposite sides of the page box for the left and right pages.</dd>
fantasai@523 269
fantasai@523 270 <dt id="facing-pages">Facing Pages</dt>
fantasai@523 271 <dd>Facing pages are two sequential pages such that when the document is duplex
fantasai@523 272 printed they are on separate sheets of paper. Typically, the earlier page will
fantasai@523 273 be the back side of one sheet and the later page will be the front side of
fantasai@523 274 another. They are usually laid out so that the binding edges of facing pages
fantasai@523 275 are vertical and adjacent when the pages are placed in their normal reading
fantasai@523 276 orientation.</dd>
fantasai@526 277
fantasai@526 278 <dt id="left-page">Left Page</dt>
fantasai@526 279 <dd>A page that would be on the left if it is part of a pair of facing pages as
fantasai@526 280 typically laid out. Page layouts for documents using a left-to-right page
fantasai@526 281 progression have the earlier of the facing pages on the left. Rules specific to
fantasai@526 282 the left page can be specified using the <span class="css">':left'</span> page
fantasai@526 283 selector.</dd>
simon@6956 284
fantasai@526 285 <dt id="right-page">Right Page</dt>
fantasai@526 286 <dd>A page that would be on the right if it is part of a pair of facing pages as
fantasai@526 287 typically laid out. Page layouts for documents using a right-to-left page
fantasai@526 288 progression have the earlier of the facing pages on the right. Rules specific
fantasai@526 289 to the right page can be specified using the <span class="css">':right'</span>
fantasai@526 290 page selector.</dd>
fantasai@213 291 </dl>
fantasai@213 292
fantasai@564 293
fantasai@564 294 <h2 id="page-box-page-rule">The Page Model</h2>
fantasai@564 295
fantasai@564 296 <p>In the paged media formatting model, the document is transferred into one
fantasai@564 297 or more page boxes. The <dfn id="page-box">page box</dfn> is a specialized CSS
fantasai@564 298 box that maps to a rectangular print media surface, such as a page of paper.
fantasai@5976 299 It is roughly analogous to the <a href="http://www.w3.org/TR/CSS21/visuren.html#viewport">viewport</a>.
fantasai@564 300 <img src="PageBox.png" style="float: right;" alt="" height="266" width="267">
fantasai@564 301
fantasai@5976 302 <p>As with other CSS <a href="http://www.w3.org/TR/CSS21/box.html">boxes</a>, a page box
fantasai@3574 303 consists of margin, border, padding, and content areas. The content and
fantasai@3574 304 margin areas of a page box have special functions:</p>
fantasai@564 305
fantasai@564 306 <ul>
fantasai@564 307 <li>The content area of a page box is called the <dfn id="page-area">page
fantasai@564 308 area</dfn>. The content of the document is flowed into one or more page boxes.
fantasai@564 309 The page area acts as a container for all the boxes generated by the root
fantasai@564 310 element and its descendants that are laid out within a given page box. The
fantasai@564 311 edges of the page area on the first page establish the rectangle that is the
fantasai@5976 312 initial <a href="http://www.w3.org/TR/CSS21/visudet.html#containing-block-details">containing block</a>
fantasai@564 313 of the document.</li>
simon@7289 314 <li>The margin area of a page box is divided into
simon@7289 315 16 <dfn>page-margin boxes</dfn>.
simon@7289 316 Each page-margin box has its own margin, border, padding and content areas.
simon@7289 317 Page-margin boxes are typically used to display running headers and footers.</li>
fantasai@564 318 </ul>
fantasai@564 319
fantasai@5973 320 <p>The properties of a <i>page box</i> are determined by properties
fantasai@5976 321 <a href="http://www.w3.org/TR/CSS21/syndata.html#declaration">declared</a> within the
fantasai@5973 322 <i>page context</i>, which is the
fantasai@5976 323 <a href="http://www.w3.org/TR/CSS21/syndata.html#x14">declaration block</a> of the
simon@7289 324 <code>@page</code> rule. Similarly the properties of a <i>page-margin box</i>
fantasai@5973 325 are determined by properties declared within its <i>margin context</i>.
fantasai@5973 326 Declarations in the page context can affect the page box and/or inherit
simon@7289 327 to the page-margin boxes, but they do not apply to or inherit into the
fantasai@564 328 document's root element or other content.</p>
fantasai@564 329
fantasai@5973 330 <p>The <i>containing block</i> of the page box is specified using the 'size'
fantasai@5973 331 property in the <i>page context</i>. The width and horizontal margins
fantasai@5973 332 of the page box are then calculated exactly as for a
fantasai@5973 333 <a href="http://www.w3.org/TR/CSS21/visudet.html#blockwidth">non-replaced
fantasai@5973 334 block element in normal flow</a>. [[!CSS21]] The height and vertical margins
fantasai@5973 335 of the page box are calculated analogously (instead of using the block height
fantasai@5973 336 formulas). In both cases if the values are over-constrained, instead of
fantasai@5973 337 ignoring any margins, the containing block is resized to coincide with the
fantasai@5973 338 margin edges of the page box.
fantasai@5973 339
fantasai@6061 340 <h3 id="painting">
fantasai@6061 341 Page Backgrounds and Painting Order</h3>
fantasai@6061 342
fantasai@6061 343 <p>When drawing a page of content, the page layers are painted in the
fantasai@6061 344 following painting order (bottommost first):
fantasai@6061 345
fantasai@6061 346 <ol>
fantasai@6061 347 <li>page background
fantasai@6061 348 <li>document canvas
fantasai@6061 349 <li>page borders
fantasai@6061 350 <li>document contents
simon@7289 351 <li>page-margin boxes
fantasai@6061 352 </ol>
fantasai@6061 353
fantasai@6061 354 <p>In the page model, the page background behaves similar to the root background:
fantasai@6061 355 its <a href="http://www.w3.org/TR/css3-background/#background-painting-area"><i>background painting area</i></a>
fantasai@6061 356 is the entire page box, including its margins.
fantasai@6065 357 Page backgrounds are anchored within the page box's padding area by default
fantasai@6061 358 (and honor 'background-origin' if the UA supports [[!CSS3BG]]).
fantasai@6061 359 However if 'background-attachment' is ''fixed''
fantasai@6061 360 then the image is positioned relative to the page box including its margins
fantasai@6061 361 (i.e. the <a href="http://www.w3.org/TR/css3-background/#background-positioning-area"><i>background positioning area</i></a>,
fantasai@6061 362 like the <i>background painting area</i>, is the page's margin box).
fantasai@6061 363
fantasai@6061 364 <p>The document canvas background is drawn as the page box's background:
fantasai@6065 365 by default its <i>background painting area</i> covers the page box's border box,
fantasai@6064 366 and for UAs that support [[!CSS3BG]], follows the 'background-clip' value specified on the root element.
fantasai@6061 367 It remains, however, positioned with respect to the root element
fantasai@6061 368 or page area as usual.
fantasai@6061 369
simon@7289 370 <p>The UA may support the <code>z-index</code> property for page-margin boxes.
simon@7289 371 With respect to the page-margin boxes,
fantasai@6061 372 the document canvas, page borders, and all of the document contents
fantasai@6061 373 are treated as a single element with a <code>z-index</code> value of '0':
simon@7289 374 the page-margin boxes never interleave with parts of the document content
fantasai@6061 375 or between the content and the canvas.
fantasai@6061 376 They may only paint in front of the document content or behind the document canvas.
fantasai@6061 377 The page background is always painted underneath everything else.
simon@7289 378 Since the <code>position</code> property does not apply to page-margin boxes,
simon@7289 379 <code>z-index</code> always affects page-margin boxes
simon@7289 380 as if they were positioned elements
simon@7289 381 regardless of the <code>position</code> property's value.
fantasai@6061 382
fantasai@6061 383 <p>The default painting order,
fantasai@6061 384 or <a href="http://www.w3.org/TR/CSS21/zindex.html">CSS2.1 Appendix E</a> "tree order",
simon@7289 385 of page-margin boxes with respect to each other is not specified.
simon@7289 386 However, the page-margin boxes are defined to come
simon@7289 387 after the page box and its contents.
fantasai@6061 388 <span class="issue">Suggestions here are welcome.</span>
fantasai@5973 389
fantasai@528 390 <h3 id="content-outside-box">Content outside the page box</h3>
fantasai@528 391
fantasai@528 392 <p>When formatting content in the page model, some content may end up outside the
fantasai@1134 393 page box. For example, an element whose 'white-space' property has the value
fantasai@1134 394 'pre' can generate a box that is wider than the page box. As another example,
fantasai@1134 395 when boxes are positioned absolutely or relatively, they may end up in
fantasai@1134 396 "inconvenient" locations. For example, images may be placed on the edge of
fantasai@1134 397 the page box or 100,000 meters below the page box. </p>
fantasai@528 398
fantasai@528 399 <p>A specification for the exact formatting of such elements lies outside the
fantasai@528 400 scope of this document. However, it is recommended that authors and user agents
fantasai@528 401 observe the following general principles concerning content outside the page
fantasai@528 402 box:</p>
fantasai@528 403
fantasai@528 404 <ul>
fantasai@1134 405 <li><p>Content should be allowed slightly beyond the page box to allow pages
fantasai@1134 406 to "bleed".
fantasai@565 407 <li><p>User agents <em class="RFC2119">SHOULD</em> avoid generating a large
fantasai@565 408 number of content-empty pages to honor the positioning of elements (e.g.,
fantasai@565 409 printing 100 blank pages is probably neither the author's nor the user's
fantasai@565 410 intent).
fantasai@565 411 A <dfn id="content-empty">Content-empty page</dfn> is a page box whose page
fantasai@565 412 area contains no printable content other than backgrounds and/or borders. A
fantasai@565 413 page box whose page area contains generated content, or content whose
fantasai@565 414 visibility is 'hidden', or invisible content such as a zero-width space is
fantasai@565 415 not a content-empty page. On the other hand, a page containing only a
simon@7289 416 background and/or borders and/or page-margin box content <em>is</em> a
fantasai@565 417 content-empty page.
fantasai@565 418 <p class="note">Note, however, that generating a small number of empty page
fantasai@565 419 boxes is sometimes necessary to honor the <span class="css">'left'</span> and
fantasai@565 420 <span class="css">'right'</span> values for <span class="property">'page-break-before'</span>
fantasai@565 421 and <span class="property">'page-break-after'</span>.</li>
fantasai@528 422
fantasai@565 423 <li><p>Authors <em class="RFC2119">SHOULD NOT</em> position elements in
fantasai@565 424 inconvenient locations just to avoid rendering them. Instead:
fantasai@565 425 <ul>
fantasai@565 426 <li>To suppress box generation entirely, set the <span class="property">'display'</span> property to <span class="css">'none'</span>.</li>
fantasai@565 427 <li>To make a box invisible, set the <span class="property">'visibility'</span>
fantasai@565 428 property.</li>
fantasai@565 429 </ul></li>
fantasai@565 430 <li><p>This specification does not define how boxes positioned outside the page
fantasai@565 431 box are handled. Possibilities include discarding them or creating page boxes
fantasai@565 432 for them at the end of the document.</li>
fantasai@565 433 </ul>
fantasai@528 434
fantasai@528 435 <h3 id="progression">Page Progression</h3>
fantasai@213 436
fantasai@526 437 <p>CSS distinguishes between left pages and right pages on all documents,
fantasai@526 438 whether they are printed duplex or not. Each left page is followed by a
fantasai@526 439 right page and vice versa. Left and right pages can be styled differently
fantasai@526 440 with the <a href="#left-right-first"><code>:left</code> and <code>:right</code>
fantasai@526 441 pseudo-classes</a>.
fantasai@213 442
fantasai@526 443 <p>Whether the first page of a document is a left page or a right page
fantasai@526 444 depends on the page progression of the document. The <dfn>page progression</dfn>
fantasai@526 445 is the direction in which the printed pages of a document would be sequenced
fantasai@557 446 when laid out side-to-side. For example, English and horizontally-set Japanese
fantasai@557 447 typically progress from left to right, whereas Arabic and vertically-set
fantasai@5987 448 Japanese pages typically progress from right to left. In documents with
fantasai@557 449 a left-to-right page progression the first page of the document is a right
fantasai@557 450 page, and vice versa.</p>
fantasai@213 451
fantasai@526 452 <p>The page progression direction is determined as follows:</p>
fantasai@213 453
fantasai@526 454 <ul>
fantasai@526 455 <li>If text is laid out in horizontal lines, the page progression is the
fantasai@526 456 same as the inline progression.</li>
fantasai@526 457 <li>If text is laid out in vertical lines, the page progression is the
fantasai@526 458 same as the block progression.</li>
fantasai@526 459 </ul>
fantasai@526 460
fantasai@5975 461 <p>If the UA supports the 'direction' and 'writing-mode' properties
fantasai@5975 462 from the CSS 3 Writing Modes Module [[CSS3-WRITING-MODES]], it must
fantasai@5975 463 <a href="http://www.w3.org/TR/css3-writing-modes/#page-direction">determine</a>
fantasai@526 464 whether the first page is a left or right page from the values of those
fantasai@526 465 properties on the root element.</p>
fantasai@526 466
fantasai@526 467 <p>To explicitly force a document to begin printing on a left or right page,
fantasai@526 468 authors can <a href="#page-break-before">insert a page break before</a> the
fantasai@526 469 first generated box. The UA must suppress the first (empty) page(s) in this
fantasai@526 470 case (and the <code>:first</code> selector applies to the first printed
fantasai@526 471 page).</p>
fantasai@213 472
simon@7334 473 <div class="example">
simon@7334 474 <pre>
simon@7334 475 html { page-break-before: always }
simon@7334 476 </pre>
simon@7334 477
simon@7334 478 <p>
simon@7334 479 For an HTML document with a left-to-right page progression,
simon@7334 480 the above style rule will cause the first page of the document
simon@7334 481 to print on a ':left' page
simon@7334 482 </p>
simon@7334 483
simon@7334 484 <pre>
simon@7334 485 html { page-break-before: left }
simon@7334 486 </pre>
simon@7334 487
simon@7334 488 <p>
simon@7334 489 For an HTML document,
simon@7334 490 the above style rule will cause the first page of the document
simon@7334 491 to print on a ':left' page,
simon@7334 492 regardless of the page progression.
simon@7334 493 </p>
simon@7334 494 </div>
simon@7334 495
fantasai@528 496 <h2 id="page-selector-and-context">Page Selectors and the Page Context</h2>
fantasai@528 497
fantasai@568 498 <h3 id="at-page-rule">The @page Rule</h3>
fantasai@568 499
fantasai@557 500 <p>Authors can specify various aspects of a page box, such as its dimensions,
simon@7290 501 orientation, and margins, within an <span class="css">@page</span> rule.
simon@7290 502 An <span class="css">@page</span> rule consists of
simon@7290 503 the keyword <span class="css">'@page'</span>,
simon@7290 504 an <em class="RFC2119">OPTIONAL</em> comma-separated list of
simon@7290 505 <i title="page selector">page selectors</i>
simon@7290 506 and a block of declarations
simon@7290 507 (said to be in the <dfn id="page-context">page context</dfn>).
fantasai@566 508 <a href="#margin-at-rules">Margin at-rules</a> may be interleaved with the
fantasai@566 509 declarations in the page context.
fantasai@528 510
simon@7290 511 <p>A <dfn id="page-selector">page selector</dfn> is either
simon@7290 512 a page pseudo-class, or
simon@7290 513 a page name followed with no intervening whitespace
simon@7290 514 by an <em class="RFC2119">OPTIONAL</em> page pseudo-class.
simon@7290 515 The page selector specifies for which pages the declarations apply.
simon@7290 516 In CSS3, page selectors can designate the first page of a document,
simon@7290 517 all left pages, all right pages, or
simon@7290 518 <a href="#using-named-pages">pages with specific names</a>.
fantasai@1101 519 Multiple selectors may be combined with a comma (which may be preceded and/or
fantasai@1101 520 followed by white space); in this case the ''@page'' rule applies to pages
fantasai@1101 521 that match any of the page selectors. (Note: this feature is at-risk.)
fantasai@1055 522 If no page selector is given, then the ''@page'' rule applies to all pages.</p>
fantasai@528 523
fantasai@528 524 <p>Properties declared within the page context apply to the page box.</p>
fantasai@528 525
fantasai@528 526 <p>If an error is encountered during the processing of a declaration block within
fantasai@5976 527 a page or a margin context, the <a href="http://www.w3.org/TR/CSS21/syndata.html#parsing-errors">Rules for handling parsing errors</a>
fantasai@528 528 apply; that is, valid declarations within the block are applied.</p>
fantasai@528 529
simon@7435 530 <h3 id="pseudo-classes">
simon@7435 531 <a id="left-right-first"></a>
simon@7435 532 Page pseudo-classes: :left, :right, :first, and :blank
simon@7435 533 </h3>
fantasai@528 534
simon@7434 535 <p>
simon@7434 536 When printing double-sided documents,
simon@7434 537 left and right pages are often formatted differently.
simon@7434 538 This can be expressed through CSS pseudo-classes defined
simon@7434 539 in the <a href="#page-context">page context</a>.
simon@7434 540 </p>
fantasai@566 541
simon@7434 542 <p>
simon@7434 543 All pages are automatically classified by user agents
simon@7434 544 as either left pages or right pages,
simon@7434 545 based on <a href="#progression">page progression</a>.
simon@7434 546 The <span class="css">':left'</span> and <span class="css">':right'</span>
simon@7434 547 page pseudo-classes can be used to selectively apply rules
simon@7434 548 to only the left or right pages, respectively.
simon@7434 549 </p>
fantasai@566 550
fantasai@566 551 <div class="example">
fantasai@566 552 The following example creates left and right binding edges using these pseudo-classes:
fantasai@566 553 <pre>
fantasai@566 554 @page :left {
fantasai@566 555 margin-left: 3cm;
fantasai@566 556 margin-right: 4cm;
fantasai@566 557 }
fantasai@566 558
fantasai@566 559 @page :right {
fantasai@566 560 margin-left: 4cm;
fantasai@566 561 margin-right: 3cm;
fantasai@566 562 }
fantasai@566 563 </pre>
fantasai@566 564 </div>
fantasai@566 565
fantasai@566 566 <p>If different declarations have been given for left and right pages, the user
fantasai@566 567 agent <em class="RFC2119">MUST</em> honor these declarations even if the user
fantasai@566 568 agent does not transfer the page boxes to left and right sheets (i.e., a
fantasai@566 569 printer that only prints on one side of the medium must nevertheless produce
fantasai@566 570 correctly formatted output).</p>
fantasai@566 571
simon@7334 572 <div class="note">
simon@7334 573 <p>
simon@7334 574 <em><strong>Note.</strong>
simon@7334 575 Adding declarations to the <span class="css">':left'</span> or
simon@7334 576 <span class="css">':right'</span> pseudo-class
simon@7334 577 does not necessarily influence whether the document
simon@7334 578 comes out of the printer double- or single-sided
simon@7334 579 (which is outside the scope of this specification).</em>
simon@7334 580 </p>
simon@7334 581 </div>
simon@7334 582
fantasai@566 583 <p>Authors can also specify style for the first page of a document with the
simon@6956 584 <span class="css">':first'</span> pseudo-class. Such style rules are applied only
fantasai@566 585 to the first printed page of a document.</p>
fantasai@566 586
fantasai@566 587 <div class="example">
fantasai@566 588 <pre>
fantasai@566 589 @page { margin: 2cm } /* All margins set to 2cm */
fantasai@566 590
fantasai@566 591 @page :first {
fantasai@566 592 margin-top: 10cm /* Top margin on first page 10cm */
fantasai@566 593 }
fantasai@566 594 </pre>
fantasai@566 595 </div>
fantasai@566 596
simon@7435 597 <p>
simon@7435 598 Blank pages that appear as a result of
simon@7435 599 <a href="http://www.w3.org/TR/css3-break/#forced-breaks">forced page breaks</a>
simon@7435 600 can be styled with the <code>:blank</code> pseudo-class.
simon@7435 601
simon@7435 602 <div class="example">
simon@7435 603 <p>In this example, forced page break may occur before <code>h1</code> elements.
simon@7435 604 <pre>
simon@7435 605 h1 { page-break-before: left }
simon@7435 606
simon@7435 607 @page :blank {
simon@7435 608 @top-center { content: "This page is intentionally left blank" }
simon@7435 609 }
simon@7435 610 </pre>
simon@7435 611 </div>
simon@7435 612
simon@7435 613 <p>
simon@7435 614 A page matched by <code>:blank</code> can also be matched
simon@7435 615 by other page pseudo-classes.
simon@7435 616
simon@7435 617 <div class="example">
simon@7435 618
simon@7435 619 <p>If headers have been specified on all right pages, a blank right
simon@7435 620 page will be matched by both <code>:blank</code>
simon@7435 621 and <code>:right</code>. Therefore, margin boxes set on right pages
simon@7435 622 will have to be removed unless they are wanted on blank pages. Here is
simon@7435 623 an example where the top center header is removed from blank pages,
simon@7435 624 while the page number remains:
simon@7435 625
simon@7435 626 <pre>
simon@7435 627 h1 { page-break-before: left }
simon@7435 628
simon@7435 629 @page :blank {
simon@7435 630 @top-center { content: none }
simon@7435 631 }
simon@7435 632
simon@7435 633 @page :right {
simon@7435 634 @top-center { content: "Preliminary edition" }
simon@7435 635 @bottom-center { content: counter(page) }
simon@7435 636 }
simon@7435 637 </pre>
simon@7435 638
simon@7435 639 <p>Due to the higher specificity of <code>:blank</code>
simon@7435 640 over <code>:right</code>, the top center header is removed even
simon@7435 641 if <code>content: none</code> comes before <code>content: "Preliminary
simon@7435 642 edition"</code>.
simon@7435 643
simon@7435 644 </div>
simon@7435 645
fantasai@566 646 <div class="note">
fantasai@566 647 <p><em><strong>Note.</strong> Future versions of CSS may include other page
fantasai@566 648 pseudo-classes.</em></p>
fantasai@566 649 </div>
fantasai@566 650
fantasai@566 651 <h3 id="syntax-page-selector">@page rule grammar</h3>
fantasai@566 652
fantasai@566 653 <p>The syntax for the @page rule is a specialization of the generic at-rule
fantasai@566 654 defined by CSS 2.1. This grammar extends the at-rule syntax to allow @page rules
fantasai@566 655 nested inside @media rules. User agents <em class="RFC2119">MUST</em> adhere
fantasai@528 656 to the following grammar:</p>
fantasai@528 657
fantasai@528 658 <p>See [[!CSS21]], Section 4.1.1 and Appendix G for the expansion of missing
fantasai@528 659 productions:</p>
fantasai@528 660 <p id="specializatons-of-ATKEYWORD">
fantasai@528 661 All new lexical tokens are specializations of the ATKEYWORD lexical token:</p>
fantasai@528 662 <pre class="lexical">
fantasai@528 663 PAGE_SYM ::= "@page"
fantasai@528 664 TOPLEFTCORNER_SYM ::= "@top-left-corner"
fantasai@528 665 TOPLEFT_SYM ::= "@top-left"
fantasai@528 666 TOPCENTER_SYM ::= "@top-center"
fantasai@528 667 TOPRIGHT_SYM ::= "@top-right"
fantasai@528 668 TOPRIGHTCORNER_SYM ::= "@top-right-corner"
simon@6956 669 BOTTOMLEFTCORNER_SYM ::= "@bottom-left-corner"
fantasai@528 670 BOTTOMLEFT_SYM ::= "@bottom-left"
fantasai@528 671 BOTTOMCENTER_SYM ::= "@bottom-center"
fantasai@528 672 BOTTOMRIGHT_SYM ::= "@bottom-right"
fantasai@528 673 BOTTOMRIGHTCORNER_SYM ::= "@bottom-right-corner"
fantasai@528 674 LEFTTOP_SYM ::= "@left-top"
fantasai@528 675 LEFTMIDDLE_SYM ::= "@left-middle"
fantasai@528 676 LEFTBOTTOM_SYM ::= "@left-bottom"
fantasai@528 677 RIGHTTOP_SYM ::= "@right-top"
fantasai@528 678 RIGHTMIDDLE_SYM ::= "@right-middle"
fantasai@528 679 RIGHTBOTTOM_SYM ::= "@right-bottom"
fantasai@528 680
simon@6956 681 <span id="syntax-prod-media">media</span> :
fantasai@528 682 MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* [ page | ruleset ]* '}' S*
fantasai@528 683 ;
fantasai@528 684
fantasai@528 685 <span id="syntax-prod-page">page</span> :
simon@7290 686 PAGE_SYM S* [ page_selector S* [ ',' page_selector S* ]* ]?
simon@7289 687 '{' S* [ [ declaration? ';' S* ] | page_margin_box ]* [ declaration ]? '}' S*
fantasai@528 688 ;
simon@7290 689 <span id="syntax-prod-page-selector">page_selector</span> :
simon@7290 690 pseudo_page | IDENT pseudo_page?
simon@7290 691 ;
fantasai@528 692 <span id="syntax-prod-pseudo-page">pseudo_page</span> :
simon@7435 693 ':' [ "left" | "right" | "first" | "blank" ]
fantasai@528 694 ;
fantasai@528 695
simon@7289 696 <span id="syntax-prod-margin">page_margin_box</span> :
fantasai@5973 697 margin_sym S* '{' S* declaration? [ ';' S* declaration? ]* '}' S*
fantasai@528 698 ;
fantasai@528 699
fantasai@528 700 <span id="syntax-prod-margin-sym">margin_sym</span> :
simon@6956 701 TOPLEFTCORNER_SYM |
simon@6956 702 TOPLEFT_SYM |
simon@6956 703 TOPCENTER_SYM |
simon@6956 704 TOPRIGHT_SYM |
fantasai@528 705 TOPRIGHTCORNER_SYM |
simon@6956 706 BOTTOMLEFTCORNER_SYM |
simon@6956 707 BOTTOMLEFT_SYM |
simon@6956 708 BOTTOMCENTER_SYM |
fantasai@528 709 BOTTOMRIGHT_SYM |
fantasai@528 710 BOTTOMRIGHTCORNER_SYM |
fantasai@528 711 LEFTTOP_SYM |
fantasai@528 712 LEFTMIDDLE_SYM |
fantasai@528 713 LEFTBOTTOM_SYM |
fantasai@528 714 RIGHTTOP_SYM |
fantasai@528 715 RIGHTMIDDLE_SYM |
simon@6956 716 RIGHTBOTTOM_SYM
fantasai@528 717 ;
fantasai@528 718 </pre>
fantasai@1101 719
fantasai@528 720 <p id="page-selector-syntax-restrict">
fantasai@1101 721 The value 'auto' is not a valid page name and must be treated as matching
fantasai@1101 722 nothing.
fantasai@528 723
fantasai@528 724 <div class="example">
fantasai@528 725
fantasai@528 726 <p>The following are examples of page selectors (declaration block intentionally
fantasai@528 727 left blank)</p>
fantasai@528 728 <pre>
fantasai@528 729 @page { ... }
fantasai@528 730 @page :left { ... }
fantasai@528 731 @page :right { ... }
fantasai@528 732 @page LandscapeTable { ... }
fantasai@528 733 @page CompanyLetterHead:first { ... } /* identifier and pseudo page. */
fantasai@528 734 @page:first { ... };
fantasai@528 735 </pre>
fantasai@528 736
simon@7289 737 <p>The following are examples of page-margin boxes
simon@7289 738 where the declaration blocks are intentionally left blank.</p>
fantasai@528 739 <pre>
fantasai@528 740 @page {
fantasai@528 741 @top-left { ... /* document name */ }
fantasai@528 742 @bottom-center { ... /* page number */}
fantasai@528 743 }
fantasai@528 744 @page :left { @left-middle { ... /* page number in left margin */ }}
fantasai@528 745 @page :right{ @right-middle { ... /* page number in right margins of right pages */}}
fantasai@528 746
fantasai@528 747 @page :left { @bottom-left-corner { ... /* left page numbers */ }}
fantasai@528 748 @page :right { @bottom-right-corner { ... /* right page numbers */ }}
fantasai@528 749 @page :first { @bottom-left-corner { ... /* empty footer on 1st page */ }
fantasai@528 750 @bottom-right-corner { ... /* empty footer */ } }
fantasai@528 751 </pre>
fantasai@528 752 </div>
fantasai@528 753
fantasai@528 754 <h3 id="cascading-and-page-context">Cascading in the page context</h3>
fantasai@528 755
fantasai@5976 756 <p>Declarations in page and margin contexts <a href="http://www.w3.org/TR/CSS21/cascade.html">cascade</a> just like declarations in <a href="http://www.w3.org/TR/CSS21/syndata.html#rule-sets">rule sets</a>.</p>
fantasai@528 757
fantasai@1101 758 <p>The specificity of page selectors is computed in a manner analogous to the
fantasai@5976 759 computations defined in the <a href="http://www.w3.org/TR/CSS21/selector.html">Selectors</a>
fantasai@528 760 module:</p>
fantasai@528 761
fantasai@528 762 <ul>
fantasai@1101 763 <li>if the page selector has a named page, f=1; else f=0</li>
simon@7435 764 <li>if the page selector has a ':first' or ':blank' pseudo-class, g=1; else g=0</li>
fantasai@1101 765 <li>if the page selector has a ':left' or ':right' pseudo-class, h=1; else h=0</li>
fantasai@528 766 </ul>
fantasai@528 767
fantasai@528 768 <p>Concatenating the three numbers f-g-h gives the specificity.</p>
fantasai@528 769
fantasai@528 770 <div class="example">
fantasai@528 771
fantasai@528 772 <p>Some page specificity calculation examples follow:</p>
fantasai@528 773 <pre>
fantasai@528 774 @page { } /* f=0 g=0 h=0 -&gt; specificity = 000 */
fantasai@528 775 @page :left { } /* f=0 g=0 h=1 -&gt; specificity = 001 */
fantasai@528 776 @page :first { } /* f=0 g=1 h=0 -&gt; specificity = 010 */
fantasai@528 777 @page artsy { } /* f=1 g=0 h=0 -&gt; specificity = 100 */
fantasai@528 778 @page artsy:left { } /* f=1 g=0 h=1 -&gt; specificity = 101 */
simon@6956 779 @page artsy:first { } /* f=1 g=1 h=0 -&gt; specificity = 110 */
fantasai@528 780 </pre>
fantasai@528 781 </div>
fantasai@528 782
fantasai@528 783 <div class="example">
fantasai@528 784
fantasai@528 785 <p>Consider the following usage example:</p>
fantasai@528 786 <pre>
fantasai@528 787 @page {
fantasai@528 788 margin-left: 3cm;
fantasai@528 789 }
fantasai@528 790
fantasai@528 791 @page :left {
fantasai@528 792 margin-left: 4cm;
fantasai@528 793 }
fantasai@528 794 </pre>
fantasai@528 795
fantasai@528 796 <p>Due to the higher specificity of the pseudo-class selector, the left margin on
fantasai@528 797 left pages will be 4cm and all other pages
fantasai@528 798 (the right-facing pages) will have a left margin of 3cm.</p>
fantasai@528 799 </div>
fantasai@528 800
fantasai@528 801 <div class="example">
fantasai@528 802
fantasai@528 803 <p>In this example, the higher specificity of the green rules wins over the red
simon@7289 804 rule.
simon@7289 805 Therefore the first page will have blue text in the top-left page-margin box
simon@7289 806 and green text in the top-right page-margin box,
simon@7289 807 while subsequent pages will have red text in the page-margin boxes.</p>
fantasai@528 808 <pre>
fantasai@528 809 @page :first {
fantasai@528 810 color: green;
fantasai@528 811
fantasai@528 812 @top-left {
fantasai@528 813 content: "foo";
fantasai@528 814 color: blue;
fantasai@528 815 }
fantasai@528 816 @top-right {
fantasai@528 817 content: "bar";
fantasai@528 818 }
fantasai@528 819 }
fantasai@528 820
fantasai@528 821 @page { color: red;
fantasai@528 822 @top-center {
fantasai@528 823 content: "Page " counter(page);
fantasai@528 824 }
fantasai@528 825 }
fantasai@528 826 </pre>
fantasai@528 827 </div>
fantasai@528 828
fantasai@528 829 <div class="example">
fantasai@528 830
fantasai@528 831 <p>Page contexts cascade, so the following stylesheet would style pages with 25
simon@7289 832 millimeter margins and 14 point type in the page-margin boxes:</p>
fantasai@528 833 <pre>
fantasai@528 834 @page { margin: 25mm;}
fantasai@528 835 @page { font-size: 14pt;}
fantasai@528 836 </pre>
fantasai@528 837 </div>
fantasai@528 838
simon@7289 839 <h2 id="margin-boxes">Page-Margin Boxes</h2>
fantasai@528 840
simon@7289 841 <p>Page-margin boxes are boxes within the page margin that,
simon@7289 842 like pseudo-elements, can contain generated content.</p>
fantasai@528 843
simon@7289 844 <p>Page-margin boxes can be used to create page headers and footers,
simon@7289 845 which are portions of the page set aside for supplementary
simon@7289 846 information such as the page number or document title.</p>
fantasai@528 847
fantasai@528 848 <div class="example">
fantasai@566 849 <p>Typically, a <dfn>page header</dfn> is located at the top of the page in
fantasai@566 850 documents with a predominately horizontal writing direction and on the side
fantasai@566 851 opposite the <a href="#binding-edge">binding edge</a> for documents with a
fantasai@566 852 predominately vertical writing direction. One possible design of page headers
simon@7289 853 for horizontally written documents uses the
simon@7289 854 <span class="css">'top-left-corner'</span>, <span class="css">'top-left'</span>,
fantasai@566 855 <span class="css">'top-center'</span>, <span class="css">'top-right'</span> and
simon@7289 856 <span class="css">'top-right-corner'</span> page-margin boxes.
simon@7289 857 Another design, for vertically written documents, could use the
simon@7289 858 <span class="css">'right-top'</span>, <span class="css">'right-middle'</span>,
simon@7289 859 and <span class="css">'right-bottom'</span> page-margin boxes for
simon@7289 860 <a href="#right-page">right facing pages</a> and
simon@7289 861 <span class="css">'left-top'</span>,
fantasai@566 862 <span class="css">'left-middle'</span>, and <span class="css">'left-bottom'</span> for <a href="#left-page">left facing pages</a>.</p>
fantasai@566 863
fantasai@566 864 <p>The <dfn>page footer</dfn> is typically at the opposite end of the page from
fantasai@566 865 the page header. For example, the design of a horizontally written document with
fantasai@566 866 a page header at the top of the page could use the <span class="css">'bottom-left-corner'</span>, <span class="css">'bottom-left'</span>,
simon@7289 867 <span class="css">'bottom-center'</span>,
simon@7289 868 <span class="css">'bottom-right'</span> and
simon@7289 869 <span class="css">'bottom-right-corner'</span>
simon@7289 870 page-margin boxes as the page footer.
simon@7289 871 The design of a vertically written document could use the page-margin boxes
simon@7289 872 of the binding edge of the page for the page footer.</p>
fantasai@566 873 </div>
fantasai@566 874
simon@7289 875 <p>Page-margin boxes are positioned with respect to the page area
simon@7289 876 and are independent of page orientation,
simon@7289 877 for example the top page-margin boxes are above the page area
simon@7289 878 in both portrait and landscape orientation.
simon@7289 879 The various page-margin boxes are defined
fantasai@566 880 and illustrated in the diagram below:
fantasai@566 881
simon@7289 882 <table id="margin-box-def" class="data" summary="defintion of each of the page-margin boxes">
simon@7289 883 <caption>Table 1 Page-Margin Box Definitions</caption>
fantasai@566 884 <thead>
fantasai@566 885 <tr>
fantasai@566 886 <th>Box</th>
fantasai@566 887 <th>Description</th>
fantasai@566 888 <th>Placement</th>
fantasai@566 889 </tr>
fantasai@566 890 </thead>
fantasai@566 891 <tbody>
fantasai@566 892 <tr id="top-margin-boxes-def">
fantasai@566 893 <th id="top-left-corner-box-def">top-left-corner</th>
fantasai@566 894 <td>a fixed-size box defined by the intersection of the top and left margins of the
fantasai@566 895 page box</td>
fantasai@566 896 <td><img src="TopLeftCornerBox.png" alt="the top left corner box with margin, border, and padding, nested within intersection of the page's top and left margins"
fantasai@566 897 height="47" width="181"></td>
fantasai@566 898 </tr>
fantasai@566 899 <tr id="top-left-box-def">
fantasai@566 900 <th>top-left</th>
fantasai@566 901 <td>a variable-width box filling the top page margin between the top-left-corner
simon@7289 902 and top-center page-margin boxes</td>
fantasai@566 903 <td><img src="TopLeftMarginBox.png" alt="the top left box with margin, border, and padding, nested in the page's top margin next to the top left corner box"
fantasai@566 904 height="47" width="181"></td>
fantasai@566 905 </tr>
fantasai@566 906 <tr id="top-center-box-def">
fantasai@566 907 <th>top-center</th>
fantasai@566 908 <td>a variable-width box centered horizontally between the page's left and right
fantasai@566 909 border edges and filling the page top margin between the top-left and top-right
simon@7289 910 page-margin boxes</td>
fantasai@566 911 <td><img src="TopCenterMarginBox.png" alt="the top center box with margin, border, and padding, centered within the page's top margin"
fantasai@566 912 height="47" width="181"></td>
fantasai@566 913 </tr>
fantasai@566 914 <tr id="top-right-box-def">
fantasai@566 915 <th>top-right</th>
fantasai@566 916 <td>a variable-width box filling the top page margin between the top-center and
simon@7289 917 top-right-corner page-margin boxes</td>
fantasai@566 918 <td><img src="TopRightMarginBox.png" alt="the top right box with margin, border, and padding, nested within the page's top margin"
fantasai@566 919 height="47" width="181"></td>
fantasai@566 920 </tr>
fantasai@566 921 <tr>
fantasai@566 922 <th id="top-right-corner-box-def">top-right-corner</th>
fantasai@566 923 <td>a fixed-size box defined by the intersection of the top and right margins of
fantasai@566 924 the page box</td>
fantasai@566 925 <td><img src="TopRightCornerMarginBox.png" alt="the top right corner box with margin, border, and padding, nested within the intersection of the page's top and right margin"
fantasai@566 926 height="47" width="181"></td>
fantasai@566 927 </tr>
fantasai@566 928 <tr id="left-margin-boxes-def">
fantasai@566 929 <th id="left-top-box-def">left-top</th>
fantasai@566 930 <td>a variable-height box filling the left page margin between the top-left-corner
simon@7289 931 and left-middle page-margin boxes</td>
simon@7289 932 <td rowspan="3"><img src="LeftMarginBoxes.png" alt="left-top, left-middle, and left-bottom page-margin boxes in the page box's left margin"
fantasai@566 933 height="226" width="181"></td>
fantasai@566 934 </tr>
fantasai@566 935 <tr id="left-middle-box-def">
fantasai@566 936 <th>left-middle</th>
fantasai@566 937 <td>a variable-height box centered vertically between the page's top and bottom
fantasai@566 938 border edges and filling the left page margin between the left-top and
simon@7289 939 left-bottom page-margin boxes</td>
fantasai@566 940 </tr>
fantasai@566 941 <tr id="left-bottom-box-def">
fantasai@566 942 <th>left-bottom</th>
fantasai@566 943 <td>a variable-height box filling the left page margin between the left-middle and
simon@7289 944 bottom-left-corner page-margin boxes</td>
fantasai@566 945 </tr>
fantasai@566 946 <tr id="right-margin-boxes-def">
fantasai@566 947 <th id="right-top-box-def">right-top</th>
fantasai@566 948 <td>a variable-height box filling the right page margin between the
simon@7289 949 top-right-corner and right-middle page-margin boxes</td>
simon@7289 950 <td rowspan="3"><img src="RightMarginBoxes.png" alt="right-top, right-middle, and right-bottom page-margin boxes in the page box's right margin"
fantasai@566 951 height="226" width="181"></td>
fantasai@566 952 </tr>
fantasai@566 953 <tr id="right-middle-box-def">
fantasai@566 954 <th>right-middle</th>
fantasai@566 955 <td>a variable-height box centered vertically between the page's top and bottom
fantasai@566 956 border edges and filling the right page margin between the right-top and
simon@7289 957 right-bottom page-margin boxes</td>
fantasai@566 958 </tr>
fantasai@566 959 <tr id="right-bottom-box-def">
fantasai@566 960 <th>right-bottom</th>
fantasai@566 961 <td>a variable-height box filling the right page margin between the right-middle
simon@7289 962 and bottom-right-corner page-margin boxes</td>
fantasai@566 963 </tr>
fantasai@566 964 <tr id="bottom-margin-boxes-def">
fantasai@566 965 <th id="bottom-left-corner-box-def">bottom-left-corner</th>
fantasai@566 966 <td>a fixed-size box defined by the intersection of the bottom and left margins of
fantasai@566 967 the page box</td>
fantasai@566 968 <td><img src="BottomLeftCornerBox.png" alt="bottom left corner box with margin, border, and padding, nested within the page margin at the intersection of the left and bottom page margins"
fantasai@566 969 height="48" width="181"></td>
fantasai@566 970 </tr>
fantasai@566 971 <tr id="bottom-left-box-def">
fantasai@566 972 <th>bottom-left</th>
fantasai@566 973 <td>a variable-width box filling the bottom page margin between the
simon@7289 974 bottom-left-corner and bottom-center page-margin boxes</td>
simon@7289 975 <td><img src="BottomLeftMarginBox.png" alt="bottom left page-margin box with margin, border, and padding, nested within the page's bottom margin next to the bottom-left-corner box"
fantasai@566 976 height="48" width="181"></td>
fantasai@566 977 </tr>
fantasai@566 978 <tr id="bottom-center-box-def">
fantasai@566 979 <th>bottom-center</th>
fantasai@566 980 <td>a variable-width box centered horizontally between the page's left and right
fantasai@566 981 border edges and filling the bottom page margin between the bottom-left and
simon@7289 982 bottom-right page-margin boxes</td>
fantasai@566 983 <td style="vertical-align: middle;"><img src="BottomCenterMarginBox.png" alt="bottom center box with margin, border, and padding, nested within the page's bottom margin and centered on the page"
fantasai@566 984 height="48" width="181"></td>
fantasai@566 985 </tr>
fantasai@566 986 <tr id="bottom-right-box-def">
fantasai@566 987 <th>bottom-right</th>
fantasai@566 988 <td>a variable-width box filling the bottom page margin between the bottom-center
simon@7289 989 and bottom-right-corner page-margin boxes</td>
simon@7289 990 <td><img src="BottomRightMarginBox.png" alt="bottom right page-margin box with margin, border, and padding, nested within the page's bottom margin and next to the bottom-right-corner box"
fantasai@566 991 height="48" width="181"></td>
fantasai@566 992 </tr>
fantasai@566 993 <tr id="bottom-right-corner-box-def">
fantasai@566 994 <th>bottom-right-corner</th>
fantasai@566 995 <td>a fixed-size box defined by the intersection of the bottom and right margins of
fantasai@566 996 the page box</td>
fantasai@566 997 <td><img src="BottomRightCornerBox.png" alt="bottom right corner box with margin, border, and padding, nested within the page margin at the intersection of the right and bottom page margins"
fantasai@566 998 height="48" width="181"></td>
fantasai@566 999 </tr>
fantasai@566 1000 </tbody>
fantasai@566 1001 </table>
fantasai@566 1002
simon@7289 1003 <h3 id="margin-at-rules">At-rules for page-margin boxes</h3>
fantasai@566 1004
simon@7289 1005 <p>Page-margin boxes are created by
simon@7289 1006 <a href="#margin-at-rules">margin at-rules</a>
fantasai@1738 1007 inside the <a href="#page-context">page context</a>.
fantasai@1738 1008 These rules should come after any declarations in the page context as legacy
fantasai@1738 1009 clients may not handle declarations after margin at-rules correctly.</p>
fantasai@566 1010
simon@7289 1011 <p>A <dfn id="margin-at-rule">margin at-rule</dfn> consists of an
simon@7289 1012 <a href="#specializatons-of-ATKEYWORD">ATKEYWORD</a>
simon@7289 1013 that identifies the page-margin box
fantasai@566 1014 (e.g. <span class="css">'@top-left'</span>) and a block of declarations (said
fantasai@566 1015 to be in the <dfn id="margin-context">margin context</dfn>).</p>
fantasai@566 1016
fantasai@566 1017 <div class="example">
fantasai@566 1018
fantasai@566 1019 <p>The following style sheet establishes a page header containing the title
fantasai@566 1020 ("Hamlet") on the left side and the page number, preceded by "Page ", on the
fantasai@566 1021 right side:</p>
fantasai@528 1022 <pre>
fantasai@566 1023 @page {
fantasai@566 1024 size: 8.5in 11in;
fantasai@566 1025 margin: 10%;
fantasai@528 1026
fantasai@566 1027 @top-left {
fantasai@566 1028 content: "Hamlet";
fantasai@566 1029 }
fantasai@566 1030 @top-right {
fantasai@566 1031 content: "Page " counter(page);
fantasai@566 1032 }
fantasai@528 1033 }
fantasai@528 1034 </pre>
fantasai@528 1035 </div>
fantasai@528 1036
fantasai@528 1037
simon@7289 1038 <h3 id="populating-margin-boxes">Populating page-margin boxes</h3>
fantasai@566 1039
fantasai@5969 1040 <p>As with the '':before'' and '':after'' pseudo-elements,
simon@7289 1041 a specified 'content' of ''normal'' on a page-margin box computes to ''none'',
simon@7289 1042 and the page-margin box is <dfn>generated</dfn>
simon@7289 1043 if and only if the computed value
simon@6957 1044 of its 'content' property is not 'none'.
fantasai@5968 1045 Otherwise it behaves as if it had ''display: none''.
fantasai@528 1046
fantasai@528 1047 <div class="example">
fantasai@566 1048 <p>The following style sheet creates a green box in each corner of the page
fantasai@566 1049 except the bottom-left corner.</p>
fantasai@528 1050 <pre>
fantasai@566 1051 @page {
fantasai@566 1052 @top-left-corner { content: " "; border: solid green; }
fantasai@1090 1053 @top-right-corner { content: url(foo.png); border: solid green; }
fantasai@1090 1054 @bottom-right-corner { content: counter(page); border: solid green; }
fantasai@566 1055 @bottom-left-corner { content: normal; border: solid green; }
fantasai@566 1056 }
fantasai@528 1057 </pre>
fantasai@528 1058 </div>
fantasai@528 1059
simon@7289 1060 <h3 id="margin-box-dimensions">Computing Page-margin Box Dimensions</h3>
fantasai@566 1061
simon@7289 1062 <p>The width and height of each page-margin box is determined by the rules
fantasai@1090 1063 below. These rules define the equivalent of CSS2.1 Sections 10.3 and
simon@7289 1064 10.6 for page-margin boxes.</p>
fantasai@1090 1065
fantasai@1090 1066 <p>The rules for applying 'min-height', 'max-height', 'min-width', and
simon@7289 1067 'max-width' [[!CSS21]] do apply to page-margin boxes and may imply
simon@7289 1068 a recalculation of the width, height, and/or margins
simon@7289 1069 if the dimensions resulting from the specified 'width' or 'height'
simon@7289 1070 violate their constraints.
simon@7289 1071 If the UA does not support the 'min-height' or 'min-width' properties
simon@7289 1072 then it must behave as if 'min-height' and 'min-width' were always zero.
fantasai@566 1073
simon@7289 1074 <h4 id="max-margin-dimension">Page-Margin Box Layout Terminology</h4>
fantasai@566 1075
fantasai@566 1076 <p>In addition to the box model definitions in CSS2.1 [[!CSS21]], the following
simon@7289 1077 terms are defined for use in the subsequent page-margin box calculations:</p>
fantasai@566 1078
fantasai@566 1079 <dl>
fantasai@566 1080
simon@6958 1081 <dt id="MaxBoxWidth"><dfn>max box width</dfn></dt>
simon@6958 1082 <dd>the sum of the page’s left border width, left padding,
fantasai@566 1083 <a href="#page-box">page area</a> width, right padding, and right border width.
fantasai@566 1084 In other words, it is the distance between the <a href="#page-box">page
simon@6958 1085 box</a>’s left border edge and right border edge</a>. This quantity is used
simon@7289 1086 when calculating dimensions of the top and bottom page-margin boxes.</dd>
fantasai@566 1087
simon@6958 1088 <dt id="MaxBoxHeight"><dfn>max box height</dfn></dt>
simon@6958 1089 <dd>the sum of the page’s top border width, top padding,
fantasai@566 1090 <a href="#page-box">page area</a> height, bottom padding, and bottom border
fantasai@566 1091 width. In other words, it is the distance between the <a href="#page-box">page
simon@6958 1092 box</a>’s top border edge and bottom border edge. This quantity is used when
simon@7289 1093 calculating dimensions of the left and right page-margin boxes.</dd>
fantasai@566 1094
simon@6958 1095 <dt><dfn>outer width</dfn></dt>
simon@7289 1096 <dd>the sum of a page-margin box's left and right margins, left and right border
fantasai@566 1097 widths, left and right padding, and content-box width.</dd>
fantasai@566 1098
simon@6958 1099 <dt><dfn>outer height</dfn></dt>
simon@7289 1100 <dd>the sum of a page-margin box's top and bottom margins, top and bottom border
fantasai@1626 1101 widths, top and bottom padding, and content-box height.</dd>
fantasai@566 1102 </dl>
fantasai@566 1103
simon@6958 1104 <dt><dfn>outer min-content</dfn> width</dt>
simon@6958 1105 <dd>Like the <i>outer width</i>, except that
simon@6958 1106 <a href="http://www.w3.org/TR/css3-sizing/#min-content">''min-content''</a>
simon@6958 1107 is used when 'width' is ''auto''.</dd>
simon@6957 1108
simon@6958 1109 <dt><dfn>outer max-content</dfn> width</dt>
simon@6958 1110 <dd>Like the <i>outer width</i>, except that
simon@6958 1111 <a href="http://www.w3.org/TR/css3-sizing/#max-content">''max-content''</a>
simon@6958 1112 is used when 'width' is ''auto''.</dd>
simon@6957 1113
simon@7289 1114 <p>The <dfn>containing block</dfn> for a corner page-margin box is the rectangle
fantasai@566 1115 defined by the intersection of the two page margins meeting at that corner.</p>
fantasai@566 1116
simon@7289 1117 <p>For all other page-margin boxes,
simon@7289 1118 the <dfn>containing block</dfn> is the rectangle
fantasai@566 1119 formed by the encapsulating page margin minus the containing blocks of the
simon@7289 1120 adjacent corners' page-margin boxes.
simon@7289 1121 This means that the size of this containing block is given
simon@7289 1122 in one dimension by the used page margin and in the other dimension
simon@7289 1123 by the <a href="#MaxBoxWidth">max box width</a>
simon@7289 1124 (for top and bottom page-margin boxes) or
simon@7289 1125 <a href="#MaxBoxHeight">max box height</a>
simon@7289 1126 (for left and right page-margin boxes).</p>
fantasai@566 1127
simon@7289 1128 <h4 id="margin-dimension">Page-Margin Box Variable Dimension Computation Rules</h4>
fantasai@566 1129
simon@7289 1130 <p>The following rules apply to 'top-left', 'top-center' and 'top-right'
simon@7289 1131 page-margin boxes,
simon@7289 1132 which are referred to as A, B, and C, respectively, in this section.</p>
simon@6957 1133
simon@7053 1134 <h5 id="marginbox-variabledim-margins">Margins</h5>
simon@7053 1135
simon@6957 1136 <p>If the 'margin-left' or 'margin-right' property of any of the three boxes
simon@6957 1137 computes to ''auto'', the used value is zero.</p>
simon@6957 1138
simon@7053 1139 <h5 id="marginbox-variabledim-with">Resolving ''auto'' widths</h5>
fantasai@566 1140
simon@6957 1141 <p>The following algorithm determines the used width of each box.
simon@7055 1142 For this purpose, boxes that are not <i>generated</i>
simon@7052 1143 are assumed to have a 'width' and an <i>outer width</i> of zero.
simon@7052 1144 </p>
simon@6957 1145
simon@6957 1146 <p class="note">
simon@6958 1147 Note: The high-level goals are (in order of priority) to center the middle
simon@6957 1148 box (B) if it is generated, to minimize overflow and overlap, and to
simon@6957 1149 distribute space proportionally to the amount of content.</p>
simon@6957 1150
simon@7052 1151 <ol>
simon@7052 1152 <li>
simon@7052 1153 If B is not <i>generated</i>:
simon@7052 1154 <ol>
simon@7052 1155 <li>
simon@7052 1156 If only box has 'width: auto', its used width is resolved so that
simon@7052 1157 the sum of the <i>outer width</i>s equals <i>max box width</i>.
simon@7052 1158 </li>
simon@6957 1159
simon@7052 1160 <li>
simon@7052 1161 If A and C both have 'width: auto':
simon@7052 1162 <ol>
simon@7052 1163 <li>
simon@7052 1164 Let <i>free space</i> be <i>max box width</i> minus
simon@7052 1165 A’s and C’s <i>outer min-content width</i>.
simon@7052 1166 </li>
simon@6957 1167
simon@7052 1168 <li>
simon@7052 1169 If <i>free space</i> is positive,
simon@7052 1170 let the respective <i>weight</i> for A and C be
simon@7052 1171 <i>max-content</i> minus <i>min-content</i>.
simon@7052 1172 If it is negative or zero, let the weights be <i>min-content</i>.
simon@7052 1173 In either case if both weights are zero, let them be '1px' instead.
simon@7052 1174 <span class="note">
simon@7052 1175 The '1px' value is arbitrary as long as the weights are equal.
simon@7052 1176 </span>
simon@7052 1177 </li>
simon@6957 1178
simon@7052 1179 <li>
simon@7052 1180 The respective used width is
simon@7052 1181 <i>min-content</i> + <i>free space</i> × <i>weight</i>
simon@7052 1182 ÷ sum of both weights
simon@7052 1183 </li>
simon@7052 1184 </ol>
simon@7052 1185 </li>
simon@7052 1186 </ol>
simon@7052 1187 </li>
simon@6957 1188
simon@7052 1189 <li>
simon@7052 1190 If B is <i>generated</i>:
simon@7052 1191 <ol>
simon@7052 1192 <li>
simon@7052 1193 If B has 'width: auto':
simon@7052 1194 <ol>
simon@7052 1195 <li>
simon@7052 1196 Let <i>free space</i> be <i>max box width</i>
simon@7052 1197 - 2 × max(<i>min<sub>A</sub></i>, <i>min<sub>C</sub></i>)
simon@7052 1198 - <i>min<sub>B</sub></i>,
simon@7052 1199 where <i>min</i> is a box’s <i>outer min-content width</i>
simon@7052 1200 if 'width' is ''auto'', zero otherwise.
simon@7052 1201 </li>
simon@7052 1202 <li>
simon@7052 1203 Let <i>upper limit</i> be <i>max box width</i>
simon@7052 1204 - 2 × max(<i>fixed<sub>A</sub></i>, <i>fixed<sub>C</sub></i>),
simon@7052 1205 where <i>fixed</i> is a box’s <i>outer width</i>
simon@7052 1206 if 'width' is not ''auto'', zero otherwise.
simon@7052 1207 </li>
simon@7052 1208 <li>
simon@7052 1209 If <i>free space</i> is positive,
simon@7052 1210 let the <i>weight</i> of a box be
simon@7052 1211 <i>max-content</i> minus <i>min-content</i>.
simon@7052 1212 If it is negative or zero, let the weights be <i>min-content</i>.
simon@7052 1213 </li>
simon@7052 1214 <li>
simon@7052 1215 Let <i>weight<sub>AC</sub></i> be
simon@7052 1216 max(<i>weight<sub>A</sub></i>, <i>weight<sub>C</sub></i>)
simon@7052 1217 </li>
simon@7052 1218 <li>
simon@7052 1219 If both <i>weight<sub>AC</sub></i> and <i>weight<sub>B</sub></i>
simon@7052 1220 are zero, let them be '1px' instead.
simon@7052 1221 </li>
simon@7052 1222 <li>
simon@7052 1223 B’s used width is
simon@7052 1224 min(<i>upper limit</i>,
simon@7052 1225 <i>min-content</i> +
simon@7052 1226 <i>free space</i> × <i>weight<sub>B</sub></i>
simon@7052 1227 ÷ (<i>weight<sub>AC</sub></i> + <i>weight<sub>B</sub></i>))
simon@7052 1228 </li>
simon@7052 1229 </ol>
simon@7052 1230 </li>
simon@7052 1231 <li>
simon@7052 1232 Then, if A or C has 'width: auto',
simon@7052 1233 the respective used widths are resolved so that <i>outer width</i>
simon@7052 1234 equals (<i>max box width</i> - B’s <i>outer width</i>) ÷ 2
simon@7052 1235 </li>
simon@7052 1236 </ol>
simon@7052 1237 </li>
simon@7052 1238 </ol>
simon@6957 1239
simon@7054 1240 <h5 id="marginbox-variabledim-minmax">Handling 'min-width' and 'max-width'</h5>
simon@7054 1241
simon@7054 1242 <p>
simon@7054 1243 The 'min-width' and 'max-width' properties [[CSS21]] apply to page-margin
simon@7054 1244 boxes in the variable dimension like on normal elements, except that the
simon@7054 1245 three boxes on the same side are considered together.
simon@7054 1246 </p>
simon@7054 1247
simon@7054 1248 <p>
simon@7054 1249 More precisely:
simon@7054 1250 </p>
simon@7054 1251
simon@7054 1252 <ol>
simon@7054 1253 <li>
simon@7054 1254 The tentative used widths are calculated
simon@7054 1255 (without 'min-width' and 'max-width') following the rules under
simon@7054 1256 <a href="#marginbox-variabledim-with">Resolving ''auto'' widths</a>
simon@7054 1257 above.
simon@7054 1258 </li>
simon@7054 1259 <li>
simon@7054 1260 If the tentative used width of any of the three boxes
simon@7054 1261 is greater than 'max-width', the rules above are applied again,
simon@7054 1262 but this time using the computed value of 'max-width'
simon@7054 1263 as the computed value for 'width'.
simon@7054 1264 </li>
simon@7054 1265 <li>
simon@7054 1266 If the resulting width of any of the three boxes
simon@7054 1267 is smaller than 'min-width', the rules above are applied again,
simon@7054 1268 but this time using the value of 'min-width'
simon@7054 1269 as the computed value for 'width'.
simon@7054 1270 </li>
simon@7054 1271 </ol>
simon@7054 1272
simon@7053 1273 <h5 id="marginbox-variabledim-positioning">Positioning</h5>
simon@7053 1274
simon@7053 1275 <p>
simon@7053 1276 Once the dimensions of the boxes are determined,
simon@7053 1277 they are positioned as follows:
simon@7053 1278 </p>
simon@7053 1279
simon@7053 1280 <ul>
simon@7053 1281 <li>The left outer edge of A is flush with the left edge of the
simon@7053 1282 containing block</li>
simon@7053 1283 <li>The outer area of B is centered in the containing block.</li>
simon@7053 1284 <li>The right outer edge of C is flush with the right edge of the
simon@7053 1285 containing block.</li>
simon@7053 1286 </ul>
simon@7053 1287
simon@7053 1288 <h5 id="marginbox-variabledim-others">Boxes on other sides</h5>
fantasai@566 1289
simon@7289 1290 <p>The used values for 'bottom-left', 'bottom-center' and 'bottom-right'
simon@7289 1291 page-margin boxes are established by the same rules as
simon@7289 1292 for 'top-left', 'top-center', and 'top-right', respectively.</p>
fantasai@566 1293
fantasai@566 1294 <p>The used values for 'left-top', 'left-middle' and 'left-bottom' boxes are
fantasai@566 1295 established by the same rules, with "width" replaced by "height", "left" by
fantasai@566 1296 "top", "right" by "bottom" and "center" by "middle".</p>
fantasai@566 1297
simon@7289 1298 <p>The used values for 'right-top', 'right-middle' and 'right-bottom'
simon@7289 1299 page-margin boxes
fantasai@566 1300 are established by the same rules as for 'left-top', 'left-middle' and
fantasai@566 1301 'left-bottom', respectively.</p>
fantasai@566 1302
simon@7289 1303 <h4 id="margin-constraints">Page-Margin Box Fixed Dimension Computation Rules</h4>
fantasai@566 1304
fantasai@1090 1305 <p>The rules below are used to calculate the used values of each
fantasai@566 1306 'top-left-corner', 'top-left', 'top-center', 'top-right', and
simon@7289 1307 'top-right-corner' page-margin box's 'height', 'margin-top', and 'margin-bottom'
fantasai@1090 1308 properties:</p>
fantasai@566 1309
fantasai@1090 1310 <ol>
fantasai@1090 1311 <li>The following constraint must hold among the used values of the margin
fantasai@1090 1312 box's properties:
fantasai@1090 1313 <p>'margin-top' + 'border-top-width' + 'padding-top' + 'height' +
fantasai@1090 1314 'padding-bottom' + 'border-bottom-width' + 'margin-bottom' = top page margin
fantasai@566 1315
fantasai@1090 1316 <li>If 'border-top-width' + 'padding-top' + 'height' (if it is not ''auto'')
fantasai@1090 1317 + 'padding-bottom' + 'border-bottom-width', plus 'margin-top' and/or
fantasai@1090 1318 'margin-bottom' if not ''auto'', is larger than the height of the top page
fantasai@1090 1319 margin, then any ''auto'' values for 'margin-top' or 'margin-bottom' are, for
fantasai@1090 1320 the following rules, treated as zero.
fantasai@566 1321
fantasai@1090 1322 <li>If at this point all of 'height', 'margin-top', and 'margin-bottom'
fantasai@1090 1323 have a computed value other than ''auto'', the values are said to be
fantasai@1090 1324 "over-constrained". In this case, the specified value of 'margin-top' is
fantasai@1090 1325 treated as 'auto'.
fantasai@566 1326
fantasai@1090 1327 <li>If there is now exactly one value specified as 'auto', its used value
fantasai@1090 1328 follows from the equality.
fantasai@566 1329
fantasai@1090 1330 <li>If 'height' is set to 'auto', any other 'auto' values become '0' and
fantasai@1090 1331 'height' follows from the resulting equality
fantasai@566 1332
simon@7289 1333 <li>If both 'margin-top' and 'margin-bottom' are 'auto',
simon@7289 1334 their used values are equal.
simon@7289 1335 This vertically centers the page-margin box content
simon@7289 1336 within the top page margin.
fantasai@1090 1337 </ol>
fantasai@566 1338
simon@7289 1339 <p>The same rules apply to the bottom page-margin boxes (bottom-left-corner,
fantasai@566 1340 bottom-left, bottom-center, bottom-right, and bottom-right-corner), except that
fantasai@566 1341 in the overconstrained case, the 'margin-bottom' is ignored rather than the
fantasai@566 1342 'margin-top'.</p>
fantasai@566 1343
simon@7289 1344 <p>Analogous rules govern the properties for the left and right
simon@7289 1345 page-margin boxes with respect to 'width'
simon@7289 1346 (top-left-corner, left-top, left-middle, left-bottom, and
fantasai@566 1347 bottom-left-corner; top-right-corner, right-top, right-middle, right-bottom,
fantasai@566 1348 bottom-right-corner), with 'top' replaced by 'left', 'bottom' replaced by
simon@7289 1349 'right', and 'height' replaced by 'width'.
simon@7289 1350 In the overconstrained case for left (right) page-margin boxes,
simon@7289 1351 the specified value of 'margin-left' ('margin-right') is ignored.</p>
fantasai@566 1352
simon@7289 1353 <h3 id="margin-box-ex">Page-margin box examples</h3>
fantasai@566 1354
simon@7289 1355 <p>The following is a collection of examples of page-margin box usage.</p>
fantasai@566 1356
fantasai@528 1357 <div class="example">
fantasai@566 1358
fantasai@566 1359 <p>Here is an example of a page with only a top-left header:</p>
fantasai@528 1360 <pre>
fantasai@566 1361 @page {
fantasai@566 1362 @top-left { content: "Header in Left Cell (top-left)" }
fantasai@566 1363 }
fantasai@528 1364 </pre>
fantasai@528 1365
fantasai@566 1366 <p>Because there are no contents defined for the top-center or the top-right
simon@7289 1367 page-margin boxes, the extent of the top-left page-margin box
simon@7289 1368 is allowed to cross the center of the page box.</p>
fantasai@566 1369
fantasai@566 1370 <p><img alt="Header Example 1" src="header-ex-1.png" height="177" width="737"></p>
fantasai@528 1371 </div>
fantasai@528 1372
fantasai@566 1373 <div class="example">
fantasai@566 1374
fantasai@566 1375 <p>The following is an example of a page with a centered header:</p>
fantasai@566 1376 <pre>
fantasai@566 1377 @page {
fantasai@566 1378 @top-center { content: "Header in Center Cell (top-center)" }
fantasai@566 1379 }
fantasai@566 1380 </pre>
fantasai@566 1381
fantasai@566 1382 <p><img alt="Header Example 2" src="header-ex-2.png" height="177" width="737"></p>
fantasai@528 1383 </div>
fantasai@528 1384
fantasai@566 1385 <div class="example">
fantasai@566 1386
fantasai@566 1387 <p>The following is an example of a page with a single header in the top-right
simon@7289 1388 page-margin box:</p>
fantasai@566 1389 <pre>
fantasai@566 1390 @page {
fantasai@566 1391 @top-right { content: "Header in Right Cell (top-right)" }
fantasai@566 1392 }
fantasai@566 1393 </pre>
fantasai@566 1394
fantasai@566 1395 <p>Because the content of the center cell is empty, the extent of the top-right
simon@7289 1396 page-margin box is allowed to cross the center of the page box.</p>
fantasai@566 1397
fantasai@566 1398 <p><img alt="Header Example 3" src="header-ex-3.png" height="177" width="737"></p>
fantasai@566 1399 </div>
fantasai@566 1400
fantasai@566 1401 <div class="example">
fantasai@566 1402
fantasai@566 1403 <p>The following is an example of a page with a top-center and a top-left header:</p>
fantasai@566 1404 <pre>
fantasai@566 1405 @page {
fantasai@566 1406 @top-left { content: "Left Cell (top-left)" }
fantasai@566 1407 @top-center { content: "Header in Center Cell (top-center)" }
fantasai@566 1408 }
fantasai@566 1409 </pre>
fantasai@566 1410
fantasai@566 1411 <p><img alt="Header Example 4" src="header-ex-4.png" height="177" width="737"></p>
fantasai@566 1412 </div>
fantasai@566 1413
fantasai@566 1414 <div class="example">
fantasai@566 1415
fantasai@566 1416 <p>The following is an example of a page with a top-center and a top-right header:</p>
fantasai@566 1417 <pre>
fantasai@566 1418 @page {
fantasai@566 1419 @top-center { content: "Header in Center Cell (top-center)" }
fantasai@566 1420 @top-right { content: "Right Cell (top-right)" }
fantasai@566 1421 }
fantasai@566 1422 </pre>
fantasai@566 1423
fantasai@566 1424 <p><img alt="Header Example 5" src="header-ex-5.png" height="177" width="737"></p>
fantasai@566 1425 </div>
fantasai@566 1426
fantasai@566 1427 <div class="example">
fantasai@566 1428
fantasai@566 1429 <p>The following is an example of a page with top-left and top-right headers:</p>
fantasai@566 1430 <pre>
fantasai@566 1431 @page {
fantasai@566 1432 @top-left { content: "Header in top-left with approx. "
fantasai@566 1433 "twice as many words as right cell." }
fantasai@566 1434 @top-right { content: "Right cell (top-right)" }
fantasai@566 1435 }
fantasai@566 1436 </pre>
fantasai@566 1437
fantasai@566 1438 <p>Because there are no center cell contents, the extent of the top-left is
fantasai@5974 1439 allowed to cross the center of the page box.</p>
fantasai@566 1440
fantasai@566 1441 <p><img alt="Header Example 6" src="header-ex-6.png" height="177" width="737"></p>
fantasai@528 1442 </div>
fantasai@528 1443
fantasai@528 1444 <h2 id="page-properties">Page Properties</h2>
fantasai@528 1445 <div>
fantasai@528 1446
fantasai@3574 1447 <p>The following properties, when used in the <a href="#page-context">page
fantasai@3574 1448 context</a>, apply to the page box:</p>
fantasai@528 1449
fantasai@528 1450 <ul>
fantasai@5976 1451 <li><a href="http://www.w3.org/TR/CSS21/colors.html#background-properties">background properties</a></li>
fantasai@5976 1452 <li><a href="http://www.w3.org/TR/CSS21/box.html#border-properties">border properties</a></li>
fantasai@5976 1453 <li><a href="http://www.w3.org/TR/CSS21/colors.html#propdef-color">color</a></li>
fantasai@5976 1454 <li><a href="http://www.w3.org/TR/CSS21/generate.html#counters">counter properties</a></li>
fantasai@5976 1455 <li><a href="http://www.w3.org/TR/CSS21/visuren.html#direction">direction</a>
fantasai@5976 1456 <li><a href="http://www.w3.org/TR/CSS21/fonts.html">font properties</a></li>
fantasai@5976 1457 <li><a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">line-height</a></li>
fantasai@5976 1458 <li><a href="http://www.w3.org/TR/CSS21/box.html#margin-properties">margin properties</a></li>
fantasai@5976 1459 <li><a href="http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines">outline properties</a>
fantasai@5976 1460 <li><a href="http://www.w3.org/TR/CSS21/box.html#padding-properties">padding properties</a></li>
fantasai@5976 1461 <li><a href="http://www.w3.org/TR/CSS21/generate.html#quotes-specify">quotes</a>
fantasai@528 1462 <li><a href="#page-size">size</a></li>
fantasai@5976 1463 <li><a href="http://www.w3.org/TR/CSS21/text.html">text properties</a></li>
fantasai@5976 1464 <li><a href="http://www.w3.org/TR/CSS21/visufx.html#visibility">visibility</a></li>
fantasai@528 1465 </ul>
fantasai@528 1466
fantasai@3574 1467 <p>The following properties, when used in a <a href="#margin-at-rule">margin
simon@7289 1468 context</a>, apply to page-margin boxes and their content:</p>
fantasai@528 1469
fantasai@528 1470 <ul>
fantasai@5976 1471 <li><a href="http://www.w3.org/TR/CSS21/colors.html#background-properties">background properties</a>
fantasai@5976 1472 <li><a href="http://www.w3.org/TR/CSS21/box.html#border-properties">border properties</a>
fantasai@5976 1473 <li><a href="http://www.w3.org/TR/CSS21/colors.html#propdef-color">color</a>
fantasai@5976 1474 <li><a href="http://www.w3.org/TR/CSS21/generate.html#content">content</a>
fantasai@5976 1475 <li><a href="http://www.w3.org/TR/CSS21/generate.html#counters">counter properties</a></li>
fantasai@5976 1476 <li><a href="http://www.w3.org/TR/CSS21/fonts.html">font properties</a>
fantasai@5976 1477 <li><a href="http://www.w3.org/TR/CSS21/visudet.html#the-height-property">height</a> <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-heights">properties</a>
fantasai@5976 1478 <li><a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">line-height</a>
fantasai@5976 1479 <li><a href="http://www.w3.org/TR/CSS21/box.html#margin-properties">margin properties</a>
fantasai@5976 1480 <li><a href="http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines">outline properties</a>
fantasai@5976 1481 <li><a href="http://www.w3.org/TR/CSS21/visufx.html#overflow">overflow</a>
fantasai@5976 1482 <li><a href="http://www.w3.org/TR/CSS21/box.html#padding-properties">padding properties</a>
fantasai@5976 1483 <li><a href="http://www.w3.org/TR/CSS21/generate.html#quotes-specify">quotes</a>
fantasai@5976 1484 <li><a href="http://www.w3.org/TR/CSS21/text.html">text properties</a>
fantasai@5976 1485 <li><a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">vertical-align</a>
fantasai@5976 1486 <li><a href="http://www.w3.org/TR/CSS21/visufx.html#visibility">visibility</a>
fantasai@5976 1487 <li><a href="http://www.w3.org/TR/CSS21/visudet.html#the-width-property">width</a> <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-widths">properties</a>
fantasai@5976 1488 <li><a href="http://www.w3.org/TR/CSS21/visuren.html#z-index">z-index</a>
fantasai@528 1489 </ul>
fantasai@528 1490
fantasai@528 1491 <p>A detailed list of properties that <em class="RFC2119">MUST</em> be supported
fantasai@528 1492 within page and margin contexts by a conforming implementation can be found in
fantasai@1052 1493 <a href="#properties-list">Appendix A</a>.</p>
fantasai@528 1494
fantasai@557 1495 <p>Other properties defined by [[!CSS21]] do not apply in these contexts. Behavior
fantasai@528 1496 for properties not included in CSS 2.1 and not listed here or in Appendix A is
fantasai@528 1497 undefined.</p>
fantasai@3574 1498
fantasai@528 1499 <p class="note">
fantasai@528 1500 Note: The intent of leaving other properties undefined is to allow the gradual
fantasai@528 1501 addition of appropriate CSS3 properties as they emerge, without having to
fantasai@528 1502 update this specification with each addition.</p>
fantasai@528 1503
fantasai@1133 1504 <p><a href="http://www.w3.org/TR/CSS21/cascade.html#value-stages">As with
fantasai@1133 1505 elements in the document</a>, both the page context and the margin context
fantasai@1133 1506 have a computed value for every property, even if that property does not
simon@7289 1507 apply to the page or page-margin box.</p>
fantasai@1133 1508
fantasai@566 1509 <p>The normal rules for CSS properties apply with the following exceptions:</p>
fantasai@528 1510
fantasai@528 1511 <ul>
simon@7289 1512 <li>page-margin boxes inherit from the page context.
simon@7289 1513 The page context inherits from the root element.
simon@7289 1514 However, since the previous revision of CSS Paged
fantasai@1090 1515 Media Level 3 did not specify this point, an implementation that sets
fantasai@1090 1516 inherited properties in the page context to their initial values (as for the
fantasai@1090 1517 root element) is also conformant to CSS Paged Media Level 3. Note that this
fantasai@1090 1518 exception will be removed in Level 4.
fantasai@1090 1519 <li>Values in units of ''em'' and ''ex'' are interpreted relative to the font
fantasai@1090 1520 associated with their context. When used on the 'font-size' property in the
fantasai@1090 1521 margin context, they are relative to the font of the page context. When used
fantasai@1090 1522 on the 'font-size' property in the page context, they are relative to the
fantasai@1090 1523 'font-size' of the root element. However, since a previous revision of CSS
fantasai@1090 1524 Paged Media Level 3 was ambiguous on this point, an implementation that
fantasai@1090 1525 treats ''em'' and ''ex'' on 'font-size' as relative to the initial value is
fantasai@1090 1526 also conformant to CSS Paged Media Level 3. Note that this exception will
fantasai@1090 1527 be removed in Level 4.
fantasai@528 1528 <li>Percentage values on the margin and padding properties are relative to the
fantasai@528 1529 dimensions of the containing block. For right and left values, percentages are
fantasai@528 1530 relative to the width of the containing block; for top and bottom values,
fantasai@528 1531 percentages are relative to the height of the containing block.</li>
fantasai@3574 1532 <li>The used values of 'width' and 'height' have special computation rules
simon@7289 1533 for page boxes and page-margin boxes; see <a href="#page-size">Page Size</a>
simon@7289 1534 and <a href="#margin-box-dimensions">Computing Page-Margin Box Dimensions</a>.
fantasai@6061 1535 <li>The page background is positioned and painted
fantasai@6061 1536 <a href="#painting">as described above</a>.
fantasai@566 1537 <li>The rules for counter scoping are modified <a href="page-based-counters">as
fantasai@566 1538 described below</a>.</li>
simon@7433 1539 <li>
simon@7433 1540 As on the '::before' and '::after' pseudo-elements,
simon@7433 1541 the ''normal'' value of the 'content' property computes to ''none''
simon@7433 1542 on page-margin boxes.
simon@7433 1543 </li>
simon@7289 1544 <li>On page-margin boxes, the 'vertical-align' property behaves
fantasai@5975 1545 <a href="http://www.w3.org/TR/CSS21/tables.html#height-layout">as specified for table cells</a>.
fantasai@5975 1546 It <em>always</em> performs alignment in the vertical dimension,
fantasai@5975 1547 regardless of writing mode.
fantasai@528 1548 </ul>
fantasai@528 1549
fantasai@528 1550 <p>It is <em class="RFC2119">recommended</em> that user agents establish a default
fantasai@528 1551 page margin via the user agent stylesheet that includes any non-printable area.
fantasai@528 1552 It is further <em class="RFC2119">recommended</em> that authors assume that the
fantasai@528 1553 default page area will not include unprintable regions.</p>
fantasai@528 1554
fantasai@566 1555 <h3 id="page-based-counters">Page-based counters</h3>
fantasai@566 1556
fantasai@566 1557 <p>Counters can be defined and controlled within an <span class="css">'@page'</span>
simon@7289 1558 rule, and used as content in page-margin boxes.
simon@7289 1559 This is useful for maintaining a page count.</p>
fantasai@566 1560
fantasai@566 1561 <div class="example">
fantasai@566 1562
fantasai@566 1563 <p>The following rules result in the placement of the current page number in the
fantasai@566 1564 middle of the outside margin of each page.</p>
fantasai@566 1565 <pre>
fantasai@566 1566 @page {
fantasai@566 1567 margin: 10%;
fantasai@566 1568 counter-increment: page;
fantasai@566 1569
fantasai@566 1570 @top-center {
fantasai@566 1571 font-family: sans-serif;
fantasai@566 1572 font-weight: bold;
fantasai@566 1573 font-size: 2em;
fantasai@566 1574 content: counter(page);
fantasai@566 1575 }
fantasai@566 1576 }
fantasai@566 1577 </pre>
fantasai@566 1578 </div>
fantasai@566 1579
fantasai@566 1580 <p>A 'counter-increment' within either a page or margin context causes the counter
fantasai@566 1581 to increment with the generation of each page box.</p>
fantasai@566 1582
fantasai@566 1583 <p>If a counter is reset or incremented within the page context, it is in scope
simon@7289 1584 for all page-margin boxes and obscures all counters of the same name within the
fantasai@566 1585 document.</p>
fantasai@566 1586
fantasai@566 1587 <p>If a counter is reset or incremented within a margin context, it is in scope
simon@7289 1588 for that page-margin box and obscures any counters of the same name
simon@7289 1589 in both the page context and the document.</p>
fantasai@566 1590
fantasai@566 1591 <p>If a counter that has not been reset or incremented within the margin context
fantasai@566 1592 or the page context is used by counter() or counters() in the margin context,
simon@7289 1593 then the resultant value is exactly
simon@7289 1594 as if the page-margin box were an element within
fantasai@566 1595 the document at the start of the page, inside the deepest element in the normal
fantasai@566 1596 flow that spans the page break. Use of the counter in this way does not affect
fantasai@566 1597 the calculation of the counter's value.</p>
fantasai@566 1598
fantasai@1082 1599 <p>A counter named ''page'' is automatically created and incremented on every
fantasai@1082 1600 page of the document. Specifically, the UA must automatically create and
fantasai@1082 1601 increment such a counter as if ''@page { counter-increment: page; }'' were
fantasai@1082 1602 specified. The implied ''page'' counter is a real counter, and can be directly
fantasai@1082 1603 affected using the 'counter-increment' and 'counter-reset' properties when
fantasai@1082 1604 named explicitly in those properties. It can also be used in the 'counter()'
fantasai@1082 1605 and 'counters()' function forms.</p>
fantasai@566 1606
fantasai@1101 1607 <p>Additionally, a counter named ''pages'' is automatically created by the UA.
fantasai@1101 1608 Its value is always the total number of pages in the document. (In continuous
fantasai@1101 1609 media this is always 1.) The value of ''pages'' cannot be manipulated: while
fantasai@1101 1610 'counter-reset' and 'counter-increment' statements that set it are valid, they
fantasai@1101 1611 have no effect.
fantasai@1101 1612
fantasai@566 1613 <p>In all other respects, page-associated counters behave as described in
fantasai@566 1614 [[!CSS21]], <a href="TR/CSS21/generate.html#scope">Nested Counters and
fantasai@5976 1615 Scope</a> and <a href="http://www.w3.org/TR/CSS21/syndata.html#counter">Counters</a>.</p>
fantasai@566 1616
simon@7289 1617 <h3 id="margin-text-alignment">Page-margin boxes and default values</h3>
fantasai@566 1618
fantasai@566 1619 <p>Properties used within page or margin contexts take their initial values from
fantasai@566 1620 their respective property definitions; however, user agents must behave as
fantasai@566 1621 though the values in the following table were established by rules in the UA
fantasai@566 1622 default style sheet.</p>
simon@7289 1623 <table id="margin-values" class="data" summary="definition of page-margin box default properties">
simon@7289 1624 <caption>Table 2. Default values for Page-Margin Boxes</caption>
fantasai@566 1625 <thead>
fantasai@566 1626 <tr>
simon@7289 1627 <th>Page-margin box</th>
fantasai@566 1628 <th><span class="property">'text-align'</span></th>
fantasai@566 1629 <th><span class="property">'vertical-align'</span></th>
fantasai@566 1630 </tr>
fantasai@566 1631 </thead>
fantasai@566 1632 <tbody>
fantasai@566 1633 <tr>
fantasai@566 1634 <td><a href="#top-left-corner-box-def">top-left-corner</a></td>
fantasai@566 1635 <td>right</td>
fantasai@566 1636 <td>middle</td>
fantasai@566 1637 </tr>
fantasai@566 1638 <tr>
fantasai@566 1639 <td><a href="#top-left-box-def">top-left</a></td>
fantasai@566 1640 <td>left</td>
fantasai@566 1641 <td>middle</td>
fantasai@566 1642 </tr>
fantasai@566 1643 <tr>
fantasai@566 1644 <td><a href="#top-center-box-def">top-center</a></td>
fantasai@566 1645 <td>center</td>
fantasai@566 1646 <td>middle</td>
fantasai@566 1647 </tr>
fantasai@566 1648 <tr>
fantasai@566 1649 <td><a href="#top-right-box-def">top-right</a></td>
fantasai@566 1650 <td>right</td>
fantasai@566 1651 <td>middle</td>
fantasai@566 1652 </tr>
fantasai@566 1653 <tr>
fantasai@566 1654 <td><a href="#top-right-corner-box-def">top-right-corner</a></td>
fantasai@566 1655 <td>left</td>
fantasai@566 1656 <td>middle</td>
fantasai@566 1657 </tr>
fantasai@566 1658 <tr>
fantasai@566 1659 <td><a href="#left-top-box-def">left-top</a></td>
fantasai@566 1660 <td>center</td>
fantasai@566 1661 <td>top</td>
fantasai@566 1662 </tr>
fantasai@566 1663 <tr>
fantasai@566 1664 <td><a href="#left-middle-box-def">left-middle</a></td>
fantasai@566 1665 <td>center</td>
fantasai@566 1666 <td>middle</td>
fantasai@566 1667 </tr>
fantasai@566 1668 <tr>
fantasai@566 1669 <td><a href="#left-bottom-box-def">left-bottom</a></td>
fantasai@566 1670 <td>center</td>
fantasai@566 1671 <td>bottom</td>
fantasai@566 1672 </tr>
fantasai@566 1673 <tr>
fantasai@566 1674 <td><a href="#right-top-box-def">right-top</a></td>
fantasai@566 1675 <td>center</td>
fantasai@566 1676 <td>top</td>
fantasai@566 1677 </tr>
fantasai@566 1678 <tr>
fantasai@566 1679 <td><a href="#right-middle-box-def">right-middle</a></td>
fantasai@566 1680 <td>center</td>
fantasai@566 1681 <td>middle</td>
fantasai@566 1682 </tr>
fantasai@566 1683 <tr>
fantasai@566 1684 <td><a href="#right-bottom-box-def">right-bottom</a></td>
fantasai@566 1685 <td>center</td>
fantasai@566 1686 <td>bottom</td>
fantasai@566 1687 </tr>
fantasai@566 1688 <tr>
fantasai@566 1689 <td><a href="#bottom-left-corner-box-def">bottom-left-corner</a></td>
fantasai@566 1690 <td>right</td>
fantasai@566 1691 <td>middle</td>
fantasai@566 1692 </tr>
fantasai@566 1693 <tr>
fantasai@566 1694 <td><a href="#bottom-left-box-def">bottom-left</a></td>
fantasai@566 1695 <td>left</td>
fantasai@566 1696 <td>middle</td>
fantasai@566 1697 </tr>
fantasai@566 1698 <tr>
fantasai@566 1699 <td><a href="#bottom-center-box-def">bottom-center</a></td>
fantasai@566 1700 <td>center</td>
fantasai@566 1701 <td>middle</td>
fantasai@566 1702 </tr>
fantasai@566 1703 <tr>
fantasai@566 1704 <td><a href="#bottom-right-box-def">bottom-right</a></td>
fantasai@566 1705 <td>right</td>
fantasai@566 1706 <td>middle</td>
fantasai@566 1707 </tr>
fantasai@566 1708 <tr>
fantasai@566 1709 <td><a href="#bottom-right-corner-box-def">bottom-right-corner</a></td>
fantasai@566 1710 <td>left</td>
fantasai@566 1711 <td>middle</td>
fantasai@566 1712 </tr>
fantasai@566 1713 </tbody>
fantasai@566 1714 </table>
fantasai@566 1715
fantasai@566 1716 <div class="example">
fantasai@566 1717
fantasai@566 1718 <p>This example style sheet could be used to create a centered header with the
fantasai@566 1719 current chapter name:</p>
fantasai@566 1720 <pre>body {counter-reset: chapter;}
fantasai@566 1721 div.chapter {counter-increment: chapter;}
fantasai@566 1722 @page {
fantasai@566 1723 margin: 10%;
fantasai@566 1724 @top-center { content: "Chapter" counter(chapter) }
fantasai@566 1725 }
fantasai@566 1726 </pre>
fantasai@566 1727 </div>
fantasai@566 1728
fantasai@3574 1729 <h2 id="page-size">Page Size</h2>
fantasai@213 1730
fantasai@213 1731 <p>People around the world use many different paper sizes. It is a goal of this
fantasai@213 1732 specification that web content should be adaptable to a range of different
fantasai@213 1733 sizes without having to write a specific style sheet for each paper size.</p>
fantasai@213 1734
fantasai@213 1735 <p>However, in some situations it is important that a certain page size achieves a
fantasai@213 1736 certain style. One way to achieve this goal is to utilize the 'size' property,
fantasai@213 1737 which indicates that the document should preferentially be displayed on a
fantasai@213 1738 surface of a certain size; another method is to use Media Queries [[MEDIAQ]]
fantasai@213 1739 which allow different style sheets to be applied to different page sizes.</p>
fantasai@213 1740
fantasai@528 1741 <h3 id="page-size-prop">Page size: the 'size' property</h3>
fantasai@3574 1742
fantasai@213 1743 <table class="propdef" summary="definition of the size property">
fantasai@213 1744 <tr>
fantasai@213 1745 <th>Name:
fantasai@213 1746 <td><dfn id="size">size</dfn>
fantasai@213 1747 <tr>
fantasai@213 1748 <th>Value:
fantasai@1124 1749 <td>&lt;length&gt;{1,2} | auto | [ &lt;page-size&gt; || [ portrait | landscape] ]
fantasai@213 1750 <tr>
fantasai@213 1751 <th>Initial:
fantasai@213 1752 <td>auto
fantasai@213 1753 <tr>
fantasai@213 1754 <td><em>Applies to:</em>
fantasai@213 1755 <td>page context
fantasai@213 1756 <tr>
fantasai@213 1757 <th>Inherited:
fantasai@213 1758 <td>N/A
fantasai@213 1759 <tr>
fantasai@213 1760 <th>Percentages:
fantasai@213 1761 <td>N/A
fantasai@213 1762 <tr>
fantasai@213 1763 <th>Media:
fantasai@213 1764 <td>paged
fantasai@213 1765 <tr>
fantasai@213 1766 <td><em>Computed value:</em>
fantasai@213 1767 <td>specified value
fantasai@213 1768 </table>
fantasai@213 1769
fantasai@3574 1770 <p>This property specifies the target size and orientation of the
fantasai@5973 1771 <a href="#page-box">page box</a>'s containing block.
fantasai@5973 1772 In the general case, where one page box is rendered onto one <a href="#page-sheet">page sheet</a>,
fantasai@5973 1773 the 'size' property also indicates the size of the destination page sheet.
fantasai@213 1774
fantasai@5987 1775 <p>The size of a page box can either be "absolute" (fixed size) or "scalable"
fantasai@5987 1776 (i.e., fitting available sheet sizes).
fantasai@5987 1777 The first three values in the table below can be used to create scalable page
fantasai@5987 1778 boxes.
fantasai@5987 1779 Other values define a fixed-size page box, and thereby indicate the preferred
fantasai@213 1780 output media size. When possible, output should be rendered on the media size
fantasai@5987 1781 indicated.
fantasai@5987 1782 If the specified size is not available, the rules for
fantasai@5987 1783 <a href="#renderingpages">transposing a page box to a different size</a>
fantasai@5987 1784 apply.</p>
fantasai@217 1785
fantasai@4555 1786 <p>If a <code>size</code> property declaration is qualified by a ''width'',
fantasai@4568 1787 ''height'', ''device-width'', ''device-height'', ''aspect-ratio'',
fantasai@4568 1788 ''device-aspect-ratio'' or ''orientation''
fantasai@4568 1789 media query [[!MEDIAQ]] (or other conditional on the size of the paper), then
fantasai@4555 1790 the declaration must be
fantasai@4568 1791 <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignored</a>. Media
fantasai@4568 1792 queries do not honor 'size': they assume the paper size that would be chosen
fantasai@4568 1793 if no @page rules were specified.</p>
fantasai@217 1794
fantasai@5987 1795 <p class=issue>It would be useful if media queries could respond at least
fantasai@5987 1796 to sizes specified on an unqualified @page.
fantasai@5987 1797
fantasai@217 1798 <div class="example">
fantasai@217 1799 <p>In the following example
fantasai@217 1800 <pre>
fantasai@217 1801 @page {
fantasai@217 1802 size: 4in 6in;
fantasai@217 1803 }
simon@6956 1804
fantasai@217 1805 @media (max-width: 6in) {
fantasai@217 1806 @page {
fantasai@217 1807 size: letter;
fantasai@217 1808 }
fantasai@217 1809 }
fantasai@217 1810 </pre>
fantasai@217 1811 <p>The second <code>size</code> declaration is ignored, i.e. the specified value
fantasai@217 1812 of the <code>size</code> property is <code>4in 6in</code>.
fantasai@217 1813 </div>
fantasai@217 1814
fantasai@213 1815 <table class="page-sizes">
fantasai@213 1816 <tr>
fantasai@213 1817 <th>Value</th>
fantasai@213 1818 <th>Description</th>
fantasai@213 1819 </tr>
fantasai@213 1820 <tr>
fantasai@213 1821 <td>auto</td>
fantasai@213 1822 <td>The page box will be set to a size and orientation chosen by the UA. In the
fantasai@213 1823 usual case, the page box size and orientation is chosen to match the target
fantasai@213 1824 media sheet.</td>
fantasai@213 1825 </tr>
fantasai@213 1826 <tr>
fantasai@213 1827 <td>landscape</td>
fantasai@213 1828 <td>Specifies that the page's content be printed in landscape orientation. The
fantasai@213 1829 longer sides of the page box are horizontal. If a <span class="css">'&lt;page-size&gt;'</span> is not specified, the size of the page sheet
fantasai@213 1830 is chosen by the UA.</td>
fantasai@213 1831 </tr>
fantasai@213 1832 <tr>
fantasai@213 1833 <td>portrait</td>
fantasai@213 1834 <td>Specifies that the page's content be printed in portrait orientation. The
fantasai@213 1835 shorter sides of the page box are horizontal. If a <span class="css">'&lt;page-size&gt;'</span> is not specified, the size of the page sheet
fantasai@213 1836 is chosen by the UA.</td>
fantasai@213 1837 </tr>
fantasai@213 1838 <tr>
fantasai@213 1839 <td>&lt;length&gt;</td>
fantasai@213 1840 <td>The page box will be set to the given absolute dimension(s). If only one length
fantasai@213 1841 value is specified, it sets both the width and height of the page box (i.e.,
fantasai@213 1842 the box is a square). If two length values are specified, the first establishes
fantasai@213 1843 the page box width, and the second the page box height. Values in units of
fantasai@213 1844 <span class="css">'em'</span> and <span class="css">'ex'</span> refer to the
fantasai@5988 1845 page context's font. Negative lengths are illegal.</td>
fantasai@213 1846 </tr>
fantasai@213 1847 <tr>
fantasai@213 1848 <td>&lt;page-size&gt;</td>
fantasai@213 1849 <td>A page size can be specified using one of the following media names. This is
fantasai@213 1850 the equivalent of specifying the <span class="css">'&lt;page-size&gt;'</span>
fantasai@213 1851 using length values. The definition of the the media names comes from
fantasai@213 1852 <cite>Media Standardized Names</cite> [[!PWGMSN]].
fantasai@213 1853
fantasai@213 1854 <dl>
fantasai@213 1855
fantasai@213 1856 <dt>A5</dt>
fantasai@213 1857 <dd>Equivalent to the size of ISO A5 media: 148mm wide and 210 mm high.</dd>
fantasai@213 1858
fantasai@213 1859 <dt>A4</dt>
simon@6795 1860 <dd>Equivalent to the size of ISO A4 media: 210 mm wide and 297 mm high.</dd>
fantasai@213 1861
fantasai@213 1862 <dt>A3</dt>
fantasai@213 1863 <dd>Equivalent to the size of ISO A3 media: 297mm wide and 420mm high.</dd>
fantasai@213 1864
fantasai@213 1865 <dt>B5</dt>
fantasai@213 1866 <dd>Equivalent to the size of ISO B5 media: 176mm wide by 250mm high.</dd>
fantasai@213 1867
fantasai@213 1868 <dt>B4</dt>
fantasai@213 1869 <dd>Equivalent to the size of ISO B4 media: 250mm wide by 353mm high.</dd>
fantasai@213 1870
fantasai@213 1871 <dt>letter</dt>
fantasai@213 1872 <dd>Equivalent to the size of North American letter media: 8.5 inches wide and 11
fantasai@213 1873 inches high</dd>
fantasai@213 1874
fantasai@213 1875 <dt>legal</dt>
fantasai@213 1876 <dd>Equivalent to the size of North American legal: 8.5 inches wide by 14 inches
fantasai@213 1877 high.</dd>
fantasai@213 1878
fantasai@213 1879 <dt>ledger</dt>
fantasai@213 1880 <dd>Equivalent to the size of North American ledger: 11 inches wide by 17 inches
fantasai@213 1881 high.</dd>
fantasai@213 1882 </dl></td>
fantasai@213 1883 </tr>
fantasai@213 1884 </table>
fantasai@213 1885
fantasai@213 1886 <p>The '&lt;page-size&gt;' names can be used in conjunction with 'landscape' or
fantasai@213 1887 'portrait' to indicate both size and orientation.</p>
fantasai@213 1888
fantasai@213 1889 <h4>Some examples:</h4>
fantasai@213 1890
fantasai@213 1891 <div class="example">
fantasai@213 1892 <pre>
fantasai@213 1893 @page {
fantasai@213 1894 size: A4 landscape;
fantasai@213 1895 }
fantasai@213 1896 </pre>
fantasai@213 1897
fantasai@213 1898 <p>The above example sets the width of the page box to be 297mm and the height to
fantasai@213 1899 be 210mm. The page box in this example should be rendered on a page sheet size
fantasai@213 1900 of 210 mm by 297 mm.</p>
fantasai@213 1901 </div>
fantasai@213 1902
fantasai@213 1903 <div class="example">
fantasai@213 1904
fantasai@213 1905 <p>In the following example, the outer edges of the page box will align with the
fantasai@213 1906 page. The percentage value on the <span class="property">'margin'</span>
fantasai@213 1907 property is relative to the page size so if the page sheet dimensions are 210mm
fantasai@213 1908 x 297mm (i.e., A4), the margins are 21mm and 29.7mm. Assuming there are no page
fantasai@213 1909 borders or padding set in the UA default style sheet, the resulting page area
fantasai@213 1910 is 189mm by 367.3mm (210mm-21mm by 297mm-29.7mm).</p>
fantasai@213 1911 <pre>
fantasai@213 1912 @page {
fantasai@213 1913 size: auto;/* auto is the initial value */
fantasai@213 1914 margin: 10%;
fantasai@213 1915 }
fantasai@213 1916 </pre>
fantasai@213 1917 </div>
fantasai@213 1918
fantasai@213 1919 <div class="example">
fantasai@213 1920 <pre>
fantasai@213 1921 @page {
fantasai@213 1922 size: 8.5in 11in;/* width height */
fantasai@213 1923 }
fantasai@213 1924 </pre>
fantasai@213 1925
fantasai@213 1926 <p>The above example sets the width of the page box to be 8.5 inches and the
fantasai@213 1927 height to be 11 inches. This indicates that the page sheet size should be
fantasai@213 1928 8.5"x11" and the orientation 'portrait'.</p>
fantasai@213 1929 </div>
fantasai@213 1930
fantasai@213 1931 <h4 id="page-size-media-query">Media Queries</h4>
fantasai@213 1932
fantasai@213 1933 <p>This section is informative.</p>
fantasai@213 1934
fantasai@213 1935 <p>By using Media Queries [[MEDIAQ]], one style sheet can express different
fantasai@213 1936 stylistic preferences for different page sizes. Consider this example:</p>
fantasai@213 1937
fantasai@213 1938 <div class="example" style="font-size: 10pt;">
fantasai@213 1939 <pre>
simon@6956 1940 /* style sheet for "A4" printing */
fantasai@213 1941 @media print and (width: 21cm) and (height: 29.7cm) {
fantasai@213 1942 @page {
fantasai@213 1943 margin: 3cm;
fantasai@213 1944 }
fantasai@213 1945 }
simon@6956 1946
fantasai@213 1947 /* style sheet for "letter" printing */
fantasai@213 1948 @media print and (width: 8.5in) and (height: 11in) {
fantasai@213 1949 @page {
fantasai@213 1950 margin: 1in;
fantasai@213 1951 }
fantasai@213 1952 }
fantasai@213 1953 </pre>
fantasai@213 1954 </div>
fantasai@213 1955
fantasai@213 1956 <p>In the example above, "A4" sheets are given a "3cm" page margin, and "letter"
fantasai@213 1957 sheets are given a "1in" page margin.</p>
fantasai@213 1958
fantasai@528 1959 <h3 id="renderingpages">Rendering page boxes that do not fit a page sheet</h3>
fantasai@213 1960
fantasai@213 1961 <p>If a page box does not match the target page sheet dimensions, the user agent
fantasai@5987 1962 should do one of the following (in order of preference):</p>
fantasai@213 1963
fantasai@213 1964 <ol>
fantasai@213 1965 <li>Render the page box at the indicated size on a larger page sheet.</li>
fantasai@213 1966 <li>Rotate the page box 90° if this will make the page box fit the page sheet.</li>
fantasai@213 1967 <li>Scale the page box to fit the page sheet. (The aspect ratio of the page box
fantasai@213 1968 <em class="RFC2119">should</em> be preserved.)</li>
fantasai@213 1969 <li>Reformat the page contents, including 'spilling' onto other page sheets.</li>
fantasai@213 1970 <li>Clip overflowed content (least preferred).</li>
fantasai@213 1971 </ol>
fantasai@213 1972
fantasai@213 1973 <p>The user agent <em class="RFC2119">MAY</em> wish to consult the user before
fantasai@213 1974 performing these operations.</p>
fantasai@213 1975
fantasai@528 1976 <h3 id="positioning-page-box">Positioning the page box on the sheet</h3>
fantasai@213 1977
fantasai@213 1978 <p>When the page box is smaller than the page size, the user agent <em class="RFC2119">SHOULD</em> either:</p>
fantasai@213 1979
fantasai@213 1980 <ul>
fantasai@213 1981 <li>center the page box on the sheet since this will align double-sided pages
fantasai@213 1982 and avoid accidental loss of information that is printed near the edge of the
fantasai@213 1983 sheet; or</li>
fantasai@213 1984 <li>position the page box in the upper left corner of the page sheet, as this
fantasai@213 1985 may minimize media consumption.</li>
fantasai@213 1986 </ul>
fantasai@213 1987
fantasai@213 1988 <p>The user agent <em class="RFC2119">MAY</em> wish to consult the user in this
fantasai@213 1989 regard.</p><!-- "Page selector and page context" -->
fantasai@213 1990
simon@7430 1991 <h2 id="page-breaks">
simon@7430 1992 <a id="pg-br-before-after"></a>
simon@7430 1993 <a id="page-break-before"></a>
simon@7430 1994 <a id="page-break-after"></a>
simon@7430 1995 <a id="page-break-inside"></a>
simon@7430 1996 <a id="breaks-inside"></a>
simon@7430 1997 <a id="orphans"></a>
simon@7430 1998 <a id="widows"></a>
simon@7430 1999 <a id="allowed-pg-brk"></a>
simon@7430 2000 <a id="brk-btw-blocks"></a>
simon@7430 2001 <a id="brk-btw-lines"></a>
simon@7430 2002 <a id="brk-end-block"></a>
simon@7430 2003 <a id="forced-pg-brk"></a>
simon@7430 2004 <a id="best-pg-brk"></a>
simon@7430 2005 Page Breaks
simon@7430 2006 </h2>
fantasai@213 2007
simon@7430 2008 <p>
simon@7430 2009 The [[!CSS3-BREAK]] module defines how and where CSS boxes
simon@7430 2010 can be <i>fragmented</i>, including across page breaks.
simon@7430 2011 It defines a few properties that indicate where the user agent
simon@7430 2012 <em class="RFC2119">MAY</em> or <em class="RFC2119">MUST</em> break pages,
simon@7430 2013 and on what page (left or right) the subsequent content resumes.
simon@7430 2014 Each page break ends layout in the current <a href="#page-box">page box</a>
simon@7430 2015 and causes remaining pieces of the document tree to be laid out
simon@7430 2016 in a new page box.
simon@7430 2017 </p>
fantasai@213 2018
fantasai@213 2019 <h3 id="using-named-pages">Using named pages: 'page'</h3>
fantasai@213 2020 <table class="propdef" summary="property definition">
fantasai@213 2021 <tr>
fantasai@213 2022 <th>Name:
fantasai@213 2023 <td><dfn id="page">page</dfn>
fantasai@213 2024 <tr>
fantasai@213 2025 <th>Value:
fantasai@1053 2026 <td>auto | &lt;identifier&gt;
fantasai@213 2027 <tr>
fantasai@213 2028 <th>Initial:
fantasai@576 2029 <td>auto
fantasai@213 2030 <tr>
fantasai@213 2031 <th>Applies to:
fantasai@213 2032 <td>block-level elements
fantasai@213 2033 <tr>
fantasai@213 2034 <th>Inherited:
fantasai@1053 2035 <td>no (but see prose)
fantasai@213 2036 <tr>
fantasai@213 2037 <th>Percentages:
fantasai@213 2038 <td>N/A
fantasai@213 2039 <tr>
fantasai@213 2040 <th>Media:
fantasai@213 2041 <td>paged
fantasai@213 2042 <tr>
fantasai@213 2043 <th>Computed value:
fantasai@213 2044 <td>specified value
fantasai@213 2045 </table>
simon@6956 2046
simon@7430 2047 <p>The 'page' property is used to specify a particular type of page
fantasai@7432 2048 on which an element <em class="RFC2119">MUST</em> be displayed.
fantasai@7432 2049 If necessary, a <i>forced page break</i> is introduced
fantasai@7432 2050 and a new page generated of the specified type.
fantasai@213 2051
fantasai@213 2052 <div class="example">
fantasai@213 2053
fantasai@213 2054 <p>This example will put all tables on a right-hand side landscape page (named
fantasai@213 2055 "rotated"):</p>
fantasai@213 2056 <pre>
fantasai@213 2057 @page rotated { size: landscape }
fantasai@213 2058 table { page: rotated; page-break-before: right }
fantasai@213 2059 </pre>
fantasai@213 2060 </div>
fantasai@213 2061
simon@7430 2062 <p>
simon@7430 2063 The 'page' property works as follows:
fantasai@7432 2064 If the two boxes meeting at a <a href="http://www.w3.org/TR/css3-break/#btw-blocks">Class 1</a> break point
fantasai@7432 2065 do not have the same propagated value for 'page',
fantasai@7432 2066 then a page break is forced between them,
simon@7430 2067 and the boxes after the break are rendered on a page box of the named type.
fantasai@7432 2068 The propagated value
fantasai@7432 2069 See [[!CSS3-BREAK]] for additional details on paged breaks.
simon@7430 2070 </p>
simon@7430 2071
fantasai@7432 2072
simon@7430 2073 <p>
fantasai@7432 2074 The 'page' property does not inherit.
fantasai@7432 2075 However, if the 'page' value on an element is ''auto'',
fantasai@7432 2076 then it is treated as having the same name as its nearest ancestor with a non-auto value.
fantasai@7432 2077 When indicated on the root element, the effective name is the empty string.
fantasai@1053 2078
fantasai@1053 2079 <p>Because a previous version of this specification indicated that the 'page'
fantasai@1053 2080 property is inherited, an implementation that inherits the 'page' property and
fantasai@1053 2081 treats ''auto'' as always naming the empty string remains conformant to CSS3
fantasai@1053 2082 Paged Media. Therefore authors should not explicitly specify the ''auto''
fantasai@1053 2083 value on a descendant of an element with a non-''auto'' 'page' value as the
fantasai@1053 2084 resulting behavior will be unpredictable.
fantasai@213 2085
fantasai@7432 2086 <p>
fantasai@7432 2087 Page names are case-sensitive identifiers.
fantasai@7432 2088 However the ''auto'' value, being a CSS keyword, is
fantasai@7432 2089 <a href="http://www.w3.org/TR/CSS21/syndata.html#characters">ASCII case-insensitive</a>.
fantasai@1054 2090
fantasai@213 2091 <div class="example">
fantasai@213 2092
fantasai@213 2093 <p>In this example, the two tables are rendered on landscape pages (indeed, on the
fantasai@213 2094 same page, if they fit). The page type "narrow" is used for the &lt;p&gt; after
fantasai@213 2095 the second table, as the page properties for the table element are no longer in
fantasai@213 2096 effect:</p>
fantasai@213 2097 <pre>
fantasai@213 2098 @page narrow { size: 9cm 18cm }
fantasai@213 2099 @page rotated { size: landscape }
fantasai@213 2100 div { page: narrow }
fantasai@213 2101 table { page: rotated }
fantasai@213 2102 </pre>with this document:
fantasai@213 2103 <pre>
fantasai@213 2104 &lt;div&gt;
fantasai@213 2105 &lt;table&gt;...&lt;/table&gt;
fantasai@213 2106 &lt;table&gt;...&lt;/table&gt;
fantasai@213 2107 &lt;p&gt;This text is rendered on a 'narrow' page&lt;/p&gt;
fantasai@213 2108 &lt;/div&gt;
fantasai@213 2109 </pre>
fantasai@213 2110 </div>
fantasai@213 2111
fantasai@6813 2112 <div class="example">
fantasai@6813 2113 <p>In Japanese documents, sometimes different parts of a single document
fantasai@6813 2114 will have different <i lang="ja-Latn">kihon hanmen</i>. [[JLREQ]]
fantasai@6813 2115 The 'page' property, together with ''@page'' rules specifying different page widths,
fantasai@6813 2116 can accomodate this type of layout:
fantasai@6813 2117 <pre>
fantasai@6813 2118 &lt;!DOCTYPE html>
fantasai@6813 2119 &lt;html lang="ja">
fantasai@6813 2120 &lt;style>
fantasai@6813 2121 html { writing-mode: vertical-rl;
fantasai@6813 2122 line-height: 1.6; }
fantasai@6813 2123 .main { page: main;
fantasai@6813 2124 columns: 2; column-gap: 1rem; }
fantasai@6813 2125 .index { page: index;
fantasai@6813 2126 columns: 3; column-gap: 1rem; }
fantasai@6813 2127 @page { margin: auto; /* center kihon hanmen on page */
fantasai@6813 2128 width: 40rem; } /* 1.6 &times; 25 lines */
fantasai@6813 2129 @page main { height: 61rem; } /* 2 &times; 30 chars + 1 &times; gap */
fantasai@6813 2130 @page index { height: 62rem; } /* 3 &times; 20 chars + 2 &times; gap */
fantasai@6813 2131 &lt;/style>
fantasai@6813 2132 &lt;section class="main"> ... &lt;/section>
fantasai@6813 2133 &lt;section class="index"> ... &lt;/section>
fantasai@6813 2134 &lt;/html>
fantasai@6813 2135 </pre>
fantasai@6813 2136 </div>
fantasai@6813 2137
fantasai@213 2138
fantasai@566 2139 <h2 id="image-properties">Image Properties</h2>
fantasai@213 2140
simon@7428 2141 <p class="note">This section has been moved to [[CSS3-IMAGES]].</p>
fantasai@213 2142
fantasai@563 2143 <h2 class="no-num" id="properties-list">Appendix A: Applicable CSS2.1 Properties</h2>
fantasai@213 2144
fantasai@528 2145 <h3 class="no-num">Properties that apply within the page context</h3>
fantasai@213 2146
fantasai@562 2147 <p>The following CSS 2.1 [[!CSS21]] properties apply to the page box.
fantasai@563 2148 If a conforming user agent supports any of these properties on block
fantasai@563 2149 boxes, then it must also support that property for the page box.</p>
fantasai@213 2150
fantasai@213 2151 <table class="property-list">
fantasai@561 2152 <tbody>
fantasai@5976 2153 <tr><td rowspan="2"><a href="http://www.w3.org/TR/CSS21/visuren.html#direction">bidi properties</a>
fantasai@563 2154 <td>direction
fantasai@563 2155 <tbody>
fantasai@5976 2156 <tr><td rowspan="6"><a href="http://www.w3.org/TR/CSS21/colors.html#background-properties">background properties</a>
fantasai@561 2157 <td>background-color
fantasai@561 2158 <tr><td>background-image
fantasai@561 2159 <tr><td>background-repeat
fantasai@561 2160 <tr><td>background-attachment
fantasai@561 2161 <tr><td>background-position
fantasai@561 2162 <tr><td>background
fantasai@561 2163 <tbody>
fantasai@5976 2164 <tr><td rowspan="20"><a href="http://www.w3.org/TR/CSS21/box.html#border-properties">border properties</a>
fantasai@561 2165 <td>border-top-width
fantasai@561 2166 <tr><td>border-right-width
fantasai@561 2167 <tr><td>border-bottom-width
fantasai@561 2168 <tr><td>border-left-width
fantasai@561 2169 <tr><td>border-width
fantasai@561 2170 <tr><td>border-top-color
fantasai@561 2171 <tr><td>border-right-color
fantasai@561 2172 <tr><td>border-bottom-color
fantasai@561 2173 <tr><td>border-left-color
fantasai@561 2174 <tr><td>border-color
fantasai@561 2175 <tr><td>border-top-style
fantasai@561 2176 <tr><td>border-right-style
fantasai@561 2177 <tr><td>border-bottom-style
fantasai@561 2178 <tr><td>border-left-style
fantasai@561 2179 <tr><td>border-short-style
fantasai@561 2180 <tr><td>border-top
fantasai@561 2181 <tr><td>border-right
fantasai@561 2182 <tr><td>border-bottom
fantasai@561 2183 <tr><td>border-left
fantasai@561 2184 <tr><td>border
fantasai@561 2185 <tbody>
fantasai@5976 2186 <tr><td rowspan="2"><a href="http://www.w3.org/TR/CSS21/generate.html#counters">counter properties</a>
fantasai@561 2187 <td>counter-reset
fantasai@561 2188 <tr><td>counter-increment
fantasai@561 2189 <tbody>
fantasai@5976 2190 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/colors.html#propdef-color">color</a>
fantasai@561 2191 <tbody>
fantasai@5976 2192 <tr><td rowspan="6"><a href="http://www.w3.org/TR/CSS21/fonts.html">font properties</a>
fantasai@561 2193 <td>font-family
fantasai@563 2194 <tr><td>font-size
fantasai@561 2195 <tr><td>font-style
fantasai@561 2196 <tr><td>font-variant
fantasai@561 2197 <tr><td>font-weight
fantasai@561 2198 <tr><td>font
fantasai@561 2199 <tbody>
fantasai@5976 2200 <tr><td rowspan="3"><a href="http://www.w3.org/TR/CSS21/visudet.html#the-height-property">height</a> <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-heights">properties</a>
fantasai@3574 2201 <td>height
fantasai@3574 2202 <tr><td>min-height
fantasai@3574 2203 <tr><td>max-height
fantasai@3574 2204 <tbody>
fantasai@5976 2205 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">line-height</a>
fantasai@561 2206 <tbody>
fantasai@5976 2207 <tr><td rowspan="5"><a href="http://www.w3.org/TR/CSS21/box.html#margin-properties">margin properties</a>
fantasai@561 2208 <td>margin-top
fantasai@561 2209 <tr><td>margin-right
fantasai@561 2210 <tr><td>margin-bottom
fantasai@561 2211 <tr><td>margin-left
fantasai@561 2212 <tr><td>margin
fantasai@561 2213 <tbody>
fantasai@5976 2214 <tr><td rowspan="5"><a href="http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines">outline properties</a>
fantasai@563 2215 <td>outline-width
fantasai@563 2216 <tr><td>outline-style
fantasai@563 2217 <tr><td>outline-color
fantasai@563 2218 <tr><td>outline
fantasai@563 2219 <tbody>
fantasai@5976 2220 <tr><td rowspan="5"><a href="http://www.w3.org/TR/CSS21/box.html#padding-properties">padding properties</a>
fantasai@561 2221 <td>padding-top
fantasai@561 2222 <tr><td>padding-right
fantasai@561 2223 <tr><td>padding-bottom
fantasai@561 2224 <tr><td>padding-left
fantasai@561 2225 <tr><td>padding
fantasai@561 2226 <tbody>
fantasai@5976 2227 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/generate.html#quotes-specify">quotes</a>
fantasai@561 2228 <tbody>
fantasai@5976 2229 <tr><td rowspan="8"><a href="http://www.w3.org/TR/CSS21/text.html">text properties</a>
fantasai@563 2230 <td>direction
fantasai@563 2231 <tr><td>letter-spacing
fantasai@561 2232 <tr><td>text-align
fantasai@561 2233 <tr><td>text-decoration
fantasai@563 2234 <tr><td>text-indent
fantasai@561 2235 <tr><td>text-transform
fantasai@561 2236 <tr><td>white-space
fantasai@563 2237 <tr><td>word-spacing
fantasai@561 2238 <tbody>
fantasai@5976 2239 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/visufx.html#visibility">visibility</a>
fantasai@3574 2240 <tbody>
fantasai@5976 2241 <tr><td rowspan="3"><a href="http://www.w3.org/TR/CSS21/visudet.html#the-width-property">width</a> <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-widths">properties</a>
fantasai@3574 2242 <td>width
fantasai@3574 2243 <tr><td>min-width
fantasai@3574 2244 <tr><td>max-width
fantasai@213 2245 </table>
fantasai@213 2246
simon@7289 2247 <p>Properties that apply to the page-margin boxes can also be set within
fantasai@562 2248 the page context: if inheritable or explicitly inherited (with the
simon@7289 2249 <code>inherit</code> keyword in the margin context), they will inherit
simon@7289 2250 to the page-margin boxes.</p>
fantasai@562 2251
fantasai@528 2252 <h3 class="no-num">Properties that apply within the margin contexts</h3>
fantasai@213 2253
simon@7289 2254 <p>The following CSS 2.1 [[!CSS21]] properties apply to page-margin boxes.
fantasai@563 2255 If a conforming user agents supports any of these properties on block
simon@7289 2256 boxes, then it must also support that property for page-margin boxes (except
simon@7289 2257 for <code>z-index</code>, which is optional for page-margin boxes).</p>
fantasai@562 2258
fantasai@213 2259 <table class="property-list">
fantasai@561 2260 <tbody>
fantasai@5976 2261 <tr><td rowspan="2"><a href="http://www.w3.org/TR/CSS21/visuren.html#direction">bidi properties</a>
fantasai@563 2262 <td>direction
fantasai@563 2263 <tr><td>unicode-bidi
fantasai@563 2264 <tbody>
fantasai@5976 2265 <tr><td rowspan="6"><a href="http://www.w3.org/TR/CSS21/colors.html#background-properties">background properties</a>
fantasai@561 2266 <td>background-color
fantasai@561 2267 <tr><td>background-image
fantasai@561 2268 <tr><td>background-repeat
fantasai@561 2269 <tr><td>background-attachment
fantasai@561 2270 <tr><td>background-position
fantasai@561 2271 <tr><td>background
fantasai@561 2272 <tbody>
fantasai@5976 2273 <tr><td rowspan="20"><a href="http://www.w3.org/TR/CSS21/box.html#border-properties">border properties</a>
fantasai@561 2274 <td>border-top-width
fantasai@561 2275 <tr><td>border-right-width
fantasai@561 2276 <tr><td>border-bottom-width
fantasai@561 2277 <tr><td>border-left-width
fantasai@561 2278 <tr><td>border-width
fantasai@561 2279 <tr><td>border-top-color
fantasai@561 2280 <tr><td>border-right-color
fantasai@561 2281 <tr><td>border-bottom-color
fantasai@561 2282 <tr><td>border-left-color
fantasai@561 2283 <tr><td>border-color
fantasai@561 2284 <tr><td>border-top-style
fantasai@561 2285 <tr><td>border-right-style
fantasai@561 2286 <tr><td>border-bottom-style
fantasai@561 2287 <tr><td>border-left-style
fantasai@561 2288 <tr><td>border-short-style
fantasai@561 2289 <tr><td>border-top
fantasai@561 2290 <tr><td>border-right
fantasai@561 2291 <tr><td>border-bottom
fantasai@561 2292 <tr><td>border-left
fantasai@561 2293 <tr><td>border
fantasai@561 2294 <tbody>
fantasai@5976 2295 <tr><td rowspan="2"><a href="http://www.w3.org/TR/CSS21/generate.html#counters">counter properties</a>
fantasai@561 2296 <td>counter-reset
fantasai@561 2297 <tr><td>counter-increment
fantasai@561 2298 <tbody>
fantasai@561 2299 <tr><td colspan="2"><a href="">content</a>
fantasai@561 2300 <tbody>
fantasai@5976 2301 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/colors.html#propdef-color">color</a>
fantasai@561 2302 <tbody>
fantasai@5976 2303 <tr><td rowspan="6"><a href="http://www.w3.org/TR/CSS21/fonts.html">font properties</a>
fantasai@561 2304 <td>font-family
fantasai@563 2305 <tr><td>font-size
fantasai@561 2306 <tr><td>font-style
fantasai@561 2307 <tr><td>font-variant
fantasai@561 2308 <tr><td>font-weight
fantasai@561 2309 <tr><td>font
fantasai@561 2310 <tbody>
fantasai@5976 2311 <tr><td rowspan="3"><a href="http://www.w3.org/TR/CSS21/visudet.html#the-height-property">height</a> <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-heights">properties</a>
fantasai@563 2312 <td>height
fantasai@563 2313 <tr><td>min-height
fantasai@563 2314 <tr><td>max-height
fantasai@561 2315 <tbody>
fantasai@5976 2316 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">line-height</a>
fantasai@561 2317 <tbody>
fantasai@5976 2318 <tr><td rowspan="5"><a href="http://www.w3.org/TR/CSS21/box.html#margin-properties">margin properties</a>
fantasai@561 2319 <td>margin-top
fantasai@561 2320 <tr><td>margin-right
fantasai@561 2321 <tr><td>margin-bottom
fantasai@561 2322 <tr><td>margin-left
fantasai@561 2323 <tr><td>margin
fantasai@561 2324 <tbody>
fantasai@5976 2325 <tr><td rowspan="5"><a href="http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines">outline properties</a>
fantasai@563 2326 <td>outline-width
fantasai@563 2327 <tr><td>outline-style
fantasai@563 2328 <tr><td>outline-color
fantasai@563 2329 <tr><td>outline
fantasai@563 2330 <tbody>
fantasai@5976 2331 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/visufx.html#overflow">overflow</a>
fantasai@563 2332 <tbody>
fantasai@5976 2333 <tr><td rowspan="5"><a href="http://www.w3.org/TR/CSS21/box.html#padding-properties">padding properties</a>
fantasai@561 2334 <td>padding-top
fantasai@561 2335 <tr><td>padding-right
fantasai@561 2336 <tr><td>padding-bottom
fantasai@561 2337 <tr><td>padding-left
fantasai@561 2338 <tr><td>padding
fantasai@561 2339 <tbody>
fantasai@5976 2340 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/generate.html#quotes-specify">quotes</a>
fantasai@563 2341 <tbody>
fantasai@5976 2342 <tr><td rowspan="7"><a href="http://www.w3.org/TR/CSS21/text.html">text properties</a>
fantasai@563 2343 <td>letter-spacing
fantasai@561 2344 <tr><td>text-align
fantasai@561 2345 <tr><td>text-decoration
fantasai@563 2346 <tr><td>text-indent
fantasai@561 2347 <tr><td>text-transform
fantasai@561 2348 <tr><td>white-space
fantasai@563 2349 <tr><td>word-spacing
fantasai@563 2350 <tbody>
fantasai@5976 2351 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">vertical-align</a>
fantasai@561 2352 <tbody>
fantasai@5976 2353 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/visufx.html#visibility">visibility</a>
fantasai@561 2354 <tbody>
fantasai@5976 2355 <tr><td rowspan="3"><a href="http://www.w3.org/TR/CSS21/visudet.html#the-width-property">width</a> <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-widths">properties</a>
fantasai@563 2356 <td>width
fantasai@563 2357 <tr><td>min-width
fantasai@563 2358 <tr><td>max-width
fantasai@561 2359 <tbody>
fantasai@5976 2360 <tr><td colspan="2"><a href="http://www.w3.org/TR/CSS21/visuren.html#z-index">z-index</a>
fantasai@213 2361 </table>
fantasai@213 2362
fantasai@552 2363 <h2 class="no-num" id="transfer-possibilities">Appendix B: Transfer Possibilities</h2>
fantasai@552 2364
fantasai@552 2365 <p>Often, but not always, the page box has a one-to-one correspondence to the
fantasai@552 2366 physical surface onto which the document is ultimately rendered. The CSS3 page
fantasai@552 2367 model specifies formatting within the page box, but it is the user agent's
fantasai@552 2368 responsibility to transfer the page box to the sheet. Some user agent transfer
fantasai@552 2369 possibilities that are not addressed by CSS3 include:</p>
fantasai@552 2370
fantasai@552 2371 <ul id="complex-usecases">
fantasai@552 2372 <li>Transferring one page box to one sheet (e.g. single-sided printing);</li>
fantasai@552 2373 <li>Transferring two page boxes to the front and back surfaces of the same
fantasai@552 2374 sheet (e.g. double-sided printing);</li>
fantasai@552 2375 <li>Transferring N (small) page boxes to one sheet (called "N-up");</li>
fantasai@552 2376 <li>Transferring one (large) page box to N x M sheets (called "tiling");</li>
fantasai@552 2377 <li>Creating signatures. A <dfn>signature</dfn> is a group of pages printed on
fantasai@552 2378 a sheet, which, when folded and trimmed like a book, appear in their proper
fantasai@552 2379 sequence;</li>
fantasai@552 2380 <li>Printing one document to multiple output trays;</li>
fantasai@552 2381 <li>Generating files containing print instructions.</li>
fantasai@552 2382 </ul>
fantasai@552 2383
fantasai@213 2384 <h2 class="no-num" id="references">References</h2>
fantasai@213 2385
fantasai@213 2386 <h3 class="no-num" id="normative-references">Normative References</h3><!--normative-->
fantasai@213 2387
fantasai@213 2388 <h3 class="no-num" id="informative-references">Informative References</h3><!--informative-->
fantasai@213 2389 </div>
fantasai@213 2390 </div>
fantasai@213 2391 </body>
fantasai@213 2392 </html>

mercurial