Wed, 01 Jul 2015 15:22:36 +0200
[css-overflow] Add computed value logic for overflow and contain: paint
1 <h1>CSS Overflow Module Level 3</h1>
2 <pre class="metadata">
3 Status: ED
4 Work Status: Exploring
5 ED: http://dev.w3.org/csswg/css-overflow/
6 Shortname: css-overflow
7 Group: csswg
8 Level: 3
9 TR: http://www.w3.org/TR/css-overflow-3/
10 Previous version: http://www.w3.org/TR/2013/WD-css-overflow-3-20130418/
11 Editor: L. David Baron, Mozilla, http://dbaron.org/
12 Editor: Florian Rivoal, Invited Expert, [email protected], http://florian.rivoal.net
13 Abstract: This module contains the features of CSS relating to new mechanisms of overflow handling in visual media (e.g., screen or paper). In interactive media, it describes features that allow the overflow from a fixed size container to be handled by pagination (displaying one page at a time). It also describes features, applying to all visual media, that allow the contents of an element to be spread across multiple fragments, allowing the contents to flow across multiple regions or to have different styles for different fragments.
14 !Change Log: <a href="https://hg.csswg.org/drafts/log/tip/css-overflow/Overview.bs">from 27 January 2015 to the present</a>
15 !Change Log: <a href="https://hg.csswg.org/drafts/log/tip/css-overflow/Overview.src.html">from 28 March 2013 to 27 January 2015</a>
16 !Change Log: <a href="https://hg.csswg.org/drafts/log/tip/css3-overflow/Overview.src.html">from 31 July 2012 to 27 March 2013</a>
17 </pre>
18 <!-- FIXME: Regressions from bikeshed conversion: -->
19 <!-- - Value lines in propdef tables no longer link to #values. -->
20 <!-- - no longer says "Test suite: none yet" -->
21 <!-- - Abstract has the most introductory sentence last -->
22 <!-- FIXME: other bikeshed issues -->
23 <pre class="link-defaults">
24 spec:css-transforms-1; type:property; text:transform-style
25 type: dfn; spec:css-multicol-1; text:overflow column
26 </pre>
27 <!-- FIXME: the break-* link doesn't actually work! -->
28 <pre class="anchors">
29 url: http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#the-overflow-style; type: property; text: overflow-style;
30 url: http://dev.w3.org/csswg/selectors-3/#subject; type: dfn; text: subject;
31 url: http://dev.w3.org/csswg/css-containment/#propdef-contain; type: property; text: contain
32 url: http://dev.w3.org/csswg/css-containment/#paint-containment; type: dfn; text: paint containment
33 </pre>
34 <style>
35 table.source-demo-pair {
36 width: 100%;
37 }
39 .in-cards-demo {
40 width: 13em;
41 height: 8em;
43 padding: 4px;
44 border: medium solid blue;
45 margin: 6px;
47 font: medium/1.3 Times New Roman, Times, serif;
48 white-space: nowrap;
49 }
51 .bouncy-columns-demo {
52 width: 6em;
53 height: 10em;
54 float: left;
55 margin: 1em;
56 font: medium/1.25 Times New Roman, Times, serif;
57 white-space: nowrap;
58 }
59 .bouncy-columns-demo.one {
60 background: aqua; color: black;
61 transform: rotate(-3deg);
62 }
63 .bouncy-columns-demo.two {
64 background: yellow; color: black;
65 transform: rotate(3deg);
66 }
68 .article-font-inherit-demo {
69 font: 1em/1.25 Times New Roman, Times, serif;
70 white-space: nowrap;
71 }
72 .article-font-inherit-demo.one {
73 width: 12em;
74 font-size: 1.5em;
75 margin-bottom: 1em;
76 height: 4em;
77 }
78 .article-font-inherit-demo.two {
79 width: 11em;
80 margin-left: 5em;
81 margin-right: 2em;
82 }
84 .dark-columns-demo {
85 width: 6em;
86 height: 10em;
87 float: left;
88 margin-right: 1em;
89 font: medium/1.25 Times New Roman, Times, serif;
90 white-space: nowrap;
91 }
92 .dark-columns-demo.one {
93 background: aqua; color: black;
94 }
95 .dark-columns-demo.one :link {
96 color: blue;
97 }
98 .dark-columns-demo.one :visited {
99 color: purple;
100 }
101 .dark-columns-demo.two {
102 background: navy; color: white;
103 }
104 .dark-columns-demo.two :link {
105 color: aqua;
106 }
107 .dark-columns-demo.two :visited {
108 color: fuchsia;
109 }
111 .article-max-lines-demo {
112 font: 1em/1.25 Times New Roman, Times, serif;
113 white-space: nowrap;
114 }
115 .article-max-lines-demo.one::first-letter {
116 font-size: 2em;
117 line-height: 0.9;
118 }
119 .article-max-lines-demo.one {
120 font-size: 1.5em;
121 width: 16em;
122 }
123 .article-max-lines-demo.two {
124 width: 11.5em;
125 float: left; margin-right: 1em;
126 }
127 .article-max-lines-demo.three {
128 width: 11.5em;
129 float: left;
130 }
131 </style>
133 <p>
134 </p>
136 <h2 id="intro">
137 Introduction</h2>
139 <p>
140 In CSS Level 1 [[CSS1]], placing more content than would fit
141 inside an element with a specified size
142 was generally an authoring error.
143 Doing so caused the content to extend
144 outside the bounds of the element,
145 which would likely cause
146 that content to overlap with other elements.
147 </p>
149 <p>
150 CSS Level 2 [[CSS21]] introduced the 'overflow' property,
151 which allows authors to have overflow be handled by scrolling,
152 which means it is no longer an authoring error.
153 It also allows authors to specify
154 that overflow is handled by clipping,
155 which makes sense when the author's intent
156 is that the content not be shown.
157 </p>
159 <p>
160 However, scrolling is not the only way
161 to present large amounts of content,
162 and may even not be the optimal way.
163 After all, the codex replaced the scroll
164 as the common format for large written works
165 because of its advantages.
166 </p>
168 <p>
169 This specification introduces
170 a mechanism for Web pages to specify
171 that an element of a page should handle overflow
172 through pagination rather than through scrolling.
173 </p>
175 <p>
176 This specification also extends the concept of overflow
177 in another direction.
178 Instead of requiring that authors specify a single area
179 into which the content of an element must flow,
180 this specification allows authors to specify multiple fragments,
181 each with their own dimensions and styles,
182 so that the content of the element can flow from one to the next,
183 using as many as needed to place the content without overflowing.
184 </p>
186 <p>
187 In both of these cases, implementations must
188 break the content in the block-progression dimension.
189 Implementations must do this is described
190 in the CSS Fragmentation Module [[!CSS3-BREAK]].
191 </p>
193 <h2 id="overflow-concepts">Types of overflow</h2>
195 <p>
196 CSS uses the term <dfn>overflow</dfn> to describe
197 the contents of a box
198 that extend outside that one of that box's edges
199 (i.e., its <i>content edge</i>, <i>padding edge</i>,
200 <i>border edge</i>, or <i>margin edge</i>).
201 The overflow might be described as the elements or features
202 that cause this overflow,
203 the non-rectangular region occupied by these features,
204 or, more commonly,
205 as the minimal rectangle that bounds that region.
206 A box's overflow is computed based on the boxes and styles
207 of the box and of all its descendants whose containing block chain
208 <span class="issue">undefined term?</span>
209 includes the box.
210 </p>
212 <p>
213 In most cases, any of these types of overflow
214 can be computed for any box
215 from the bounds and properties of that box,
216 and from the overflow (of that type)
217 of each of its children.
218 However, this is not always the case; for example,
219 when ''transform-style: preserve-3d'' [[CSS3-TRANSFORMS]] is used on
220 some of the children, their descendants with
221 ''transform-style: preserve-3d'' must also be examined.
222 </p>
224 <h3 id="ink-overflow">Ink overflow</h3>
226 <p>
227 The <dfn id="ink-overflow0">ink overflow</dfn> of a box
228 is the part of that box and its contents that
229 creates a visual effect outside of
230 the box's border box.
231 </p>
233 <p>
234 Since some effects in CSS (for example, the blurs in
235 'text-shadow' [[CSS3TEXT]] and 'box-shadow' [[CSS3BG]])
236 do not define what visual extent they cover, the extent
237 of the <a>ink overflow</a> is undefined.
238 </p>
240 <p class="issue">
241 Should we try to define it at all and just leave pieces undefined?
242 </p>
244 <p>
245 The <dfn>ink overflow region</dfn> is the non-rectangular region
246 occupied by the <a>ink overflow</a>, and the
247 <dfn>ink overflow rectangle</dfn> is
248 the minimal rectangle whose axis is aligned to the box's axes
249 and contains the <a>ink overflow region</a>.
250 Note that the <a>ink overflow rectangle</a> is a rectangle
251 in the box's coordinate system, but might be non-rectangular
252 in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
253 </p>
255 <h3 id="scrollable-overflow">Scrollable overflow</h3>
257 <p>
258 The <dfn id="scrollable-overflow0">scrollable overflow</dfn> of a box is the
259 set of things extending outside of that box's padding edge
260 for which a scrolling mechanism needs to be provided.
261 </p>
263 <p class="issue">
264 The following definition should be rewritten to use
265 the concept of <a href="http://dev.w3.org/csswg/css-transforms/#3d-rendering-context">3D rendering context</a> [[!CSS3-TRANSFORMS]]
266 and related terms,
267 particularly once those concepts stabilize following changes
268 proposed in the CSS WG meeting on the morning of 2014-01-28.
269 </p>
271 <p>
272 Given the following definitions
273 <span class="issue">which belong in [[CSS3-TRANSFORMS]]</span>:
274 </p>
276 <dl>
277 <dt><dfn>3d-preserving child</dfn></dt>
278 <dd>
279 A child box B of a containing block C is a 3d-preserving
280 child if it has ''transform-style: preserve-3d''
281 and the user-agent is not required to flatten it
282 based on the <a href="http://www.w3.org/TR/css3-transforms/#transform-style-property">requirements</a> in [[!CSS3-TRANSFORMS]].
283 </dt>
284 <dt><dfn>non-3d-preserving child</dfn></dt>
285 <dd>
286 A child C of a box P is a non-3d-preserving-child if
287 it is not a <a>3d-preserving child</a>.
288 </dd>
289 <dt><dfn>3d-preserving descendant</dfn></dt>
290 <dd>
291 Box D is a 3d-preserving descendant of box A if A is
292 an ancestor of D, and D and all of the boxes (if any)
293 in the containing block chain from D to A
294 are <a>3d-preserving child</a> boxes.
295 </dd>
296 </dl>
298 <p>The scrollable overflow of a box is the union of the following things,
299 all adjusted for transforms <span class="issue">undefined concept!</span> into the box's coordinate space:</p>
301 <ul>
302 <li>
303 for the box and all of its <a>3d-preserving descendant</a> boxes:
304 <ul>
305 <li>the box's own padding edge (for the box itself) or border edge (for <a>3d-preserving descendant</a> boxes)</li>
306 <li>the bounds <span class="issue">undefined term!</span> of any text directly in the box</li>
307 <li><span class="issue">MORE HERE!</span>
308 </ul>
309 <li>
310 for all the <a>non-3d-preserving child</a> boxes of the
311 box and its <a>3d-preserving descendant</a> boxes,
312 the scrollable overflow of the box
313 </li>
314 </ul>
316 <p class="issue">
317 I wrote this definition off the top of my head,
318 so it can't possibly be right.
319 It's missing tons of pieces!
320 </p>
322 <p class="issue">
323 The handling of preserve-3d subtrees here is probably wrong;
324 the elements should probably count
325 only towards the overflow of the element that flattens them.
326 </p>
328 <p>
329 The <dfn>scrollable overflow region</dfn> is the non-rectangular region
330 occupied by the <a>scrollable overflow</a>, and the
331 <dfn>scrollable overflow rectangle</dfn> is
332 the minimal rectangle whose axis is aligned to the box's axes
333 and contains the <a>scrollable overflow region</a>.
334 Note that the <a>scrollable overflow rectangle</a> is a rectangle
335 in the box's coordinate system, but might be non-rectangular
336 in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
337 </p>
339 <h3 id="border-box-overflow">Border box overflow</h3>
341 <p class="issue">
342 This concept has been proposed for some uses, such as for
343 determining what the 'outline' property goes around, and
344 as the basis of a coordinate system for specifying clips and masks,
345 but it's not clear if it's needed.
346 </p>
348 <p>
349 The <dfn>border-box overflow</dfn> of a box is the
350 union of the box's border edge and the border edges of
351 the box's descendants.</p>
352 </p>
354 <p class="issue">
355 If needed, define more formally, as for scrollable overflow above.
356 (Maybe even share the definitions in an appropriate way!)
357 </p>
359 <p>
360 The <dfn>border-box overflow region</dfn> is the non-rectangular region
361 occupied by the <a>border-box overflow</a>, and the
362 <dfn>border-box overflow rectangle</dfn> is
363 the minimal rectangle whose axis is aligned to the box's axes
364 and contains the <a>border-box overflow region</a>.
365 Note that the <a>border-box overflow rectangle</a> is a rectangle
366 in the box's coordinate system, but might be non-rectangular
367 in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
368 </p>
370 <h2 id="overflow-properties">Overflow properties</h2>
372 <p>
373 The 'overflow-x' property specifies
374 the handling of overflow in the horizontal direction
375 (i.e., overflow from the left and right sides of the box),
376 and the 'overflow-y' property specifies the handling
377 of overflow in the vertical direction
378 (i.e., overflow from the top and bottom sides of the box)
379 </p>
381 <pre class=propdef>
382 Name: overflow-x, overflow-y
383 Value: ''visible'' | ''hidden'' | ''clip'' | ''scroll'' | ''auto''
384 Initial: ''visible''
385 Applies to: block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
386 Inherited: no
387 Percentages: N/A
388 Media: visual
389 Computed value: see below
390 Animatable: no
391 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
392 </pre>
394 <p>
395 The 'overflow' property is a shorthand property
396 that sets the specified values of both 'overflow-x' and 'overflow-y'
397 to the value specified for 'overflow'.
398 </p>
400 <pre class=propdef>
401 Name: overflow
402 Value: ''visible'' | ''hidden'' | ''clip'' | ''scroll'' | ''auto''
403 Initial: see individual properties
404 Applies to: block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
405 Inherited: no
406 Percentages: N/A
407 Media: visual
408 Computed value: see individual properties
409 Animatable: no
410 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
411 </pre>
413 <div id="overflow-computed-values">
414 <p>The computed values of 'overflow-x' and 'overflow-y'
415 are determined from the cascaded values [[!CSS3CASCADE]]
416 based on the following rules:</p>
418 <ol>
419 <li>
420 If one cascaded values is ''overflow/visible''
421 and the other is not,
422 then computed values are the cascaded values
423 with ''overflow/visible'' changed to ''overflow/auto''.
424 </li>
425 <li>
426 Otherwise, if both cascaded values are ''overflow/visible''
427 and the computed value of 'contain' is
428 one that activates <a>paint containment</a>
429 (e.g. ''contain:strict''
430 or ''contain: paint''
431 or ''contain: layout paint''â¦),
432 then the computed values of both 'overflow-x' and 'overflow-y'
433 are changed to ''overflow/clip''.</li>
434 <li>
435 Otherwise, the computed values are as specified.
436 </li>
437 </ol>
438 </div>
440 <p>The values of these properties are:</p>
442 <dl dfn-for="overflow, overflow-x, overflow-y" dfn-type="value">
443 <dt><dfn>visible</dfn>
444 <dd>
445 There is no special handling of overflow, that is, it
446 may be rendered outside the block container.
447 </dd>
448 <dt><dfn>hidden</dfn>
449 <dd>This value indicates that
450 the content is clipped and that no scrolling user interface should be provided by the UA
451 to view the content outside the clipping region.
452 However, the content may still be scrolled programatically,
453 for example using the mechanisms defined in [[CSSOM-VIEW]].
454 <dt><dfn>clip</dfn>
455 <dd>Like ''hidden'',
456 this value indicates that
457 the content is clipped
458 and that no scrolling user interface should be provided by the UA
459 to view the content outside the clipping region.
460 In addition, unlike ''overflow: hidden''
461 which still allows programmatic scrolling,
462 ''overflow: clip'' forbids scrolling entirely,
463 through any mechanism.
465 Issue: Mozilla implements -moz-hidden-unscrollable,
466 which is similar to ''clip'',
467 except that it does not cause the element to establish a BFC.
468 Should we match that?
469 <dt><dfn>scroll</dfn>
470 <dd>This value indicates that the content is clipped
471 and that if the user agent uses a scrolling mechanism
472 that is visible on the screen (such as a scroll bar or a panner),
473 that mechanism should be displayed for a box
474 whether or not any of its content is clipped.
475 This avoids any problem with scrollbars appearing
476 and disappearing in a dynamic environment.
477 When this value is specified and the target medium is ''print'',
478 overflowing content may be printed.
479 <dt><dfn>auto</dfn>
480 <dd>The behavior of the ''overflow/auto'' value is user agent-dependent,
481 but should cause a scrolling mechanism to be provided for overflowing boxes.
482 </dl>
484 Even if 'overflow' is set to ''overflow/visible'',
485 content may be clipped to a UA's document window by the native operating environment.
487 If the computed value of 'overflow' is not ''overflow/visible'',
488 the element creates a block formatting context.
490 UAs must apply the 'overflow' property
491 set on the root element to the viewport.
492 HTML UAs must instead apply the âoverflowâ property
493 from the <{body}> element to the viewport
494 if the value on the root element is ''visible''.
495 The ''visible'' value when used for the viewport
496 must be interpreted as ''overflow/auto''.
497 The element from which the value is propagated
498 must have a used value for 'overflow' of ''visible''.
500 In the case of a scrollbar being placed on an edge of the element's box,
501 it should be inserted between the inner border edge
502 and the outer padding edge.
503 Any space taken up by the scrollbars should be
504 taken out of (subtracted from the dimensions of)
505 the containing block formed by the element with the scrollbars.
507 Issue: import examples from [[CSS3-BOX]].
509 <p class="issue">
510 Explain which directions allow scrolling and which don't,
511 as a function of 'direction'
512 (including propagation of 'direction' to the ICB).
513 </p>
516 <p class="issue">
517 [[CSS3-MARQUEE]] describes an 'overflow-style' property,
518 but it has not picked up implementation experience
519 that the working group is aware of.
520 Should this document treat 'overflow-style' as a defunct proposal,
521 or should this document describe the 'overflow-style' property
522 and attempt to revive it,
523 despite that implementations have implemented
524 'overflow-x' and 'overflow-y' instead?
525 </p>
527 <h2 id="fragmentation">Fragmentation of overflow</h2>
529 The 'continue' property gives authors the ability
530 to request that content that does not fit inside an element
531 be fragmented (in the sense of [[!CSS3-BREAK]]),
532 and provides alternatives
533 for where the remaining content should continue.
535 Notably, this property explains traditional pagination,
536 and extends it further.
538 <pre class=propdef>
539 Name: continue
540 Value: ''auto'' | ''overflow'' | ''paginate'' | ''fragments'' | ''discard''
541 Initial: auto
542 Applies to: block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
543 Inherited: no
544 Percentages: N/A
545 Media: visual
546 Computed value: see below
547 Animatable: no
548 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
549 </pre>
551 Issue: The naming of this property and its values is preliminary.
552 This was initially proposed as
553 "fragmentation: auto | none | break | clone | page"
554 in <a href="https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html">https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html</a>,
555 and there is not yet wide agreement as to which naming is better.
557 Issue: This property is meant to generalize and replace 'region-fragment'.
558 Once it is sufficiently stable in this specification,
559 'region-fragment' should be removed from the regions specification in favor of this.
561 Note: ''continue: fragments'' replaces "overflow:fragments"
562 from earlier versions of this specification,
563 while ''continue: paginate'' replaces "overflow: paged-x | paged-y | paged-x-controls | paged-y-controls"
565 <dl dfn-for="continue" dfn-type="value">
566 <dt><dfn>auto</dfn>
567 <dd>''continue/auto'' may only occur as a computed value
568 if the element is a <a spec="css-regions">CSS Region</a>
569 other than the last one in a <a spec="css-regions">region chain</a>.
570 Content that doesn't fit is pushed to the next region of the chain.
572 In all other cases, ''continue/auto'' computes to one of the other values.
574 <dt><dfn>overflow</dfn>
575 <dd>Content that doesn't fit overflows, according to the 'overflow' property
577 <dt><dfn>discard</dfn>
578 <dd>Content that doesn't fit is discarded at a fragmentation break
580 Note: generalized from region-fragment: break; on the last region of a region chain
582 Issue: When the element isn't a <a spec="css-break">fragmentation container</a> already,
583 should this work by turning it directly into one,
584 or by creating a <a>fragment box</a> inside it like ''continue/fragments'' does?
586 <dt><dfn>paginate</dfn>
587 <dd>Content that doesn't fit paginates.
588 This creates a paginated view inside the element
589 similar to the way that 'overflow: scroll' creates a scrollable view.
591 See <a href="#paginated-overflow">paginated overflow</a>
593 Note: Print is effectively "continue: paginate" on the root.
594 <dt><dfn>fragments</dfn>
595 <dd>content that doesn't fit causes the element to copy itself and continue laying out.
597 See <a href="#fragment-overflow">fragment overflow</a>.
598 </dl>
600 The computed value of the 'continue' for a given element or pseudo element is determined as follow:
601 <ol>
602 <li>If the specified value is ''continue/auto''
603 <ol>
604 <li>On a <a spec="css-regions">CSS Region</a> other than the last one in a <a spec="css-regions">region chain</a>,
605 the computed value is ''continue/auto''
606 <li>On a page
607 the computed value is ''continue/paginate''
608 <li>On a <a>fragment box</a>
609 the computed value is ''continue/fragments''
610 <li>Otherwise, the computed value is ''continue/overflow''
611 </ol>
612 <li>If the specified value is ''continue/framgents''
613 <ol>
614 <li>On a page
615 the computed value is ''continue/paginate''
616 <li>Otherwise, the computed value is the specified value
617 </ol>
618 <li>In all other cases, the computed value is the specified value
619 </ol>
621 Issue: If we introduce a pseudo element that can select columns in a multicol,
622 we would need to specify that auto computes to auto on it,
623 or introduce a new value and have auto compute to that
624 (but what would that value compute to on things that aren't columns?).
626 Note: For background discussions leading to this property, see these threads:
627 <a href="http://lists.w3.org/Archives/Public/www-style/2012May/1197.html">discussion of overflow, overflow-x, overflow-y and overflow-style</a> and
628 <a href="https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html">proposal for a fragmentation property</a>
630 <h2 id="paginated-overflow">Paginated overflow</h2>
632 This section introduces and defines the meaning of the ''continue/paginate'' value of the 'continue' property.
634 Issue: Write this section
636 Issue: Pages should be possible to style with @page rules. How does that work for nested pages?
638 <div class="issue">
639 Should traditional pagination (e.g. when printing)
640 be expressed through some magic in the computed value of ''continue/auto'',
641 or by inserting this in the UA stylesheet:
642 <pre><code class="lang-css">
643 @media (overflow-block: paged), (overflow-block: optional-paged) {
644 :root {
645 continue: paginate;
646 }
647 }
648 </code></pre>
649 </div>
651 Issue: Traditional pagination (e.g. when printing) assumes that
652 :root is contained in the page box,
653 rather than having the page box be a pseudo element child of :root.
654 Can we work around that using something similar to fragment boxes?
655 Or maybe by having a fragment box (reproducing :root) inside a page box inside :root?
657 Issue: How does the page box model work when it is a child of a regular css box?
659 Issue: The initial proposal in [[CSS3GCPM]] and implemantation from Opera
660 used 4 values instead of ''continue/paginate'':
661 "paged-x | paged-y | paged-x-controls | paged-y-controls".
662 Should this property also include these values,
663 or are they better handled as separate properties?
664 (e.g.: "pagination-layout: auto | horizontal | vertical", "pagination-controls: auto | none")
666 Issue: Ability to display N pages at once
667 rather than just one page at once?
668 Could this be a value of "pagination-layout", such as:
669 "pagination-layout: horizontal 2;"
671 Issue: Brad Kemper has proposed a model for combining pagination and
672 fragment overflow, which also deals with displaying multiple pages.
673 <a href="http://www.w3.org/mid/[email protected]">http://www.w3.org/mid/[email protected]</a>
675 <p class="issue">
676 The current implementation of paginated overflow uses
677 the 'overflow'/'overflow-x'/'overflow-y' properties
678 rather than the 'overflow-style' property as proposed
679 in the [[CSS3GCPM]] draft
680 (which also matches the [[CSS3-MARQUEE]] proposal).
681 or the 'continue' property as described here.
682 </p>
684 <h2 id="fragment-overflow">Fragment overflow</h2>
686 This section introduces and defines the meaning of
687 the ''continue/fragments'' value of the 'continue' property.
689 <p>
690 When the computed value of 'continue' for an element is ''continue/fragments'',
691 and implementations would otherwise have created a box for the element,
692 then implementations must create a sequence of <dfn>fragment box</dfn>es
693 for that element.
694 (It is possible for an element with ''continue: fragments''
695 to generate only one <a>fragment box</a>.
696 However, if an element's computed 'continue' is not ''continue/fragments'',
697 then its box is not a <a>fragment box</a>.)
698 Every <a>fragment box</a> is a fragmentation container,
699 and any overflow
700 that would cause that fragmentation container to fragment
701 causes another <a>fragment box</a> created as a next sibling
702 of the previous one.
703 <span class="issue">Or is it as though it's a next sibling of
704 the element? Need to figure out exactly how this interacts with
705 other box-level fixup.</span>
706 Additionally, if the <a>fragment box</a> is also
707 a multi-column box (as defined in [[!CSS3COL]]
708 <span class="issue">though it defines <i>multi-column element</i></span>)
709 any content that would lead to the creation of <a>overflow columns</a> [[!CSS3COL]]
710 instead is flown into an additional fragment box.
711 However, fragment boxes may themselves be broken
712 (due to fragmentation in a fragmentation context outside of them,
713 such as pages, columns, or other fragment boxes);
714 such breaking leads to fragments of the same fragment box
715 rather than multiple fragment boxes.
716 (This matters because fragment boxes may be styled by their index;
717 such breaking leads to multiple fragments of a fragment box
718 with a single index.
719 This design choice is so that
720 breaking a fragment box across pages does not break
721 the association of indices to particular pieces of content.)
722 <span class="issue">Should a forced break that breaks to
723 an outer fragmentation context cause a new fragment of a single
724 fragment box or a new fragment box?</span>
725 <span class="issue">Should we find a term other than
726 <a>fragment box</a> here to make this a little less confusing?</span>
727 </p>
729 <p class="issue">
730 What if we want to be able to style the pieces of an element
731 split within another type of fragmentation context?
732 These rules prevent ever using ''::nth-fragment()'' for that,
733 despite that the name seems the most logical name for such a feature.
734 </p>
736 <div class="example">
737 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
738 <title>Breaking content into
739 equal-sized cards</title>
740 <style>
741 .in-cards {
742 continue: fragments;
744 width: 13em;
745 height: 8em;
747 padding: 4px;
748 border: medium solid blue;
749 margin: 6px;
751 font: medium/1.3 Times New
752 Roman, Times, serif;
753 }
754 </style>
755 <div class="in-cards">
756 In this example, the text in the div
757 is broken into a series of cards.
758 These cards all have the same style.
759 The presence of enough content to
760 overflow one of the cards causes
761 another one to be created. The second
762 card is created just like it's the
763 next sibling of the first.
764 </div></pre></td><td>
765 <div class="in-cards-demo">In this example, the text in the<br>div is broken into a series of<br>cards. These cards all have the<br>same style. The presence of<br>enough content to overflow<br>one of the cards causes another</div>
766 <div class="in-cards-demo">one to be created. The second<br>card is created just like it's the<br>next sibling of the first.</div>
767 </td></tr></table>
768 </div>
770 <p class="issue">
771 We should specify that ''continue: fragments'' does not apply
772 to at least some table parts,
773 and perhaps other elements as well.
774 We need to determine exactly which ones.
775 </p>
777 <p class="issue">
778 This specification needs to say which type of
779 fragmentation context is created
780 so that it's clear which values of the 'break-*' properties
781 cause breaks within this context.
782 We probably want ''break-*: region'' to apply.
783 </p>
785 <p class="issue">
786 This specification needs a processing model
787 that will apply in cases where the layout containing the
788 fragments has characteristics that use the intrinsic size of the fragments
789 to change the amount of space available for them,
790 such as [[CSS3-GRID-LAYOUT]].
791 There has already been some work on such a processing model
792 in [[CSS3-REGIONS]],
793 and the work done on a model there,
794 and the editors of that specification,
795 should inform what happens in this specification.
796 </p>
798 <h3 id="fragment-styling">Fragment styling</h3>
800 <h4 id="fragment-pseudo-element">The ::nth-fragment() pseudo-element</h4>
802 <p>
803 The <dfn selector>::nth-fragment()</dfn> pseudo-element
804 is a pseudo-element
805 that describes some of the <a>fragment box</a>es generated by an element.
806 The argument to the pseudo-element takes the same syntax
807 as the argument to the :nth-child() pseudo-class
808 defined in [[!SELECT]], and has the same meaning
809 except that the number is relative to
810 <a>fragment box</a>es generated by the element
811 instead of siblings of the element.
812 </p>
814 <p class="note">
815 Selectors that allow addressing fragments
816 by counting from the end rather than the start
817 are intentionally not provided.
818 Such selectors would interfere with determining
819 the number of fragments.
820 </p>
822 <p class="issue">
823 Depending on future discussions,
824 this ''::nth-fragment(<var>an+b</var>)'' syntax
825 may be replaced with
826 the new ''::fragment:nth(<var>an+b</var>)'' syntax.
827 </p>
829 <h4 id="style-of-fragments">Styling of fragments</h4>
831 <p class="issue">
832 Should this apply to continue:fragments only,
833 or also to continue:paginate?
834 (If it applies,
835 then stricter property restrictions would be needed
836 for continue:paginate.)
837 </p>
839 <p>
840 In the absence of rules with ''::nth-fragment()'' pseudo-elements,
841 the computed style for each <a>fragment box</a>
842 is the computed style for the element
843 for which the <a>fragment box</a> was created.
844 However, the style for a <a>fragment box</a> is also influenced
845 by rules whose selector's <a>subject</a> [[!SELECT]]
846 has an ''::nth-fragment()'' pseudo-element,
847 if the 1-based number of the <a>fragment box</a> matches
848 that ''::nth-fragment()'' pseudo-element
849 and the selector (excluding the ''::nth-fragment()'' pseudo-element)
850 matches the element generating the fragments.
851 </p>
853 <p>
854 When determining the style of the <a>fragment box</a>,
855 these rules that match the fragment pseudo-element
856 cascade together with the rules that match the element,
857 with the fragment pseudo-element adding the specificity
858 of a pseudo-class to the specificity calculation.
859 <span class="issue">Does this need to be specified in
860 the cascading module as well?</span>
861 </p>
863 <div class="example">
864 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
865 <style>
866 .bouncy-columns {
867 continue: fragments;
868 width: 6em;
869 height: 10em;
870 float: left;
871 margin: 1em;
872 font: medium/1.25 Times New
873 Roman, Times, serif;
874 }
875 .bouncy-columns::nth-fragment(1) {
876 background: aqua; color: black;
877 transform: rotate(-3deg);
878 }
879 .bouncy-columns::nth-fragment(2) {
880 background: yellow; color: black;
881 transform: rotate(3deg);
882 }
883 </style>
884 <div class="bouncy-columns">
885 <i>...</i>
886 </div></pre></td><td>
887 <div class="bouncy-columns-demo one">In this<br>example, the<br>text in the div<br>is broken into<br>a series of<br>columns. The<br>author<br>probably</div>
888 <div class="bouncy-columns-demo two">intended the<br>text to fill two<br>columns. But<br>if it happens to<br>fill three<br>columns, the<br>third column is<br>still created. It</div>
889 <div class="bouncy-columns-demo">just doesn't<br>have any<br>fragment-specific<br>styling because<br>the author<br>didn't give it<br>any.</div>
890 </td></tr></table>
891 </div>
893 <p>
894 Styling an ''::nth-fragment()'' pseudo-element with the 'continue'
895 property does take effect;
896 if a <a>fragment box</a> has a
897 computed value of 'continue' other than ''fragments''
898 then that fragment box is the last fragment.
899 However, overriding 'continue' on the first fragment
900 does not cause the <a>fragment box</a> not to exist;
901 whether there are fragment boxes at all is determined by
902 the computed value of overflow for the element.
903 </p>
905 <p>
906 Styling an ''::nth-fragment()'' pseudo-element with the 'content'
907 property has no effect;
908 the computed value of 'content' for the fragment box
909 remains the same as the computed value of content for the element.
910 </p>
912 <p>
913 Specifying ''display: none'' for a <a>fragment box</a> causes
914 the fragment box with that index not to be generated.
915 However, in terms of the indices
916 used for matching ''::nth-fragment()'' pseudo-elements
917 of later fragment boxes,
918 it still counts as though it was generated.
919 However, since it is not generated, it does not contain any content.
920 </p>
922 <p>
923 Specifying other values of 'display', 'position',
924 or 'float' is permitted, but is not allowed to change
925 the computed value of 'display-inside'.
926 (Since 'continue' only
927 applies to block containers, flex containers, and grid containers
928 the computed value of 'display-inside' is always
929 ''display-inside/block'', ''display-inside/flex'', or
930 ''display-inside/grid''.
931 <span class="issue">Need to specify exactly how this works,
932 but it depends on
933 having 'display-inside' and 'display-outside' specified.</span>
934 </p>
936 <p>
937 To match the model for other pseudo-elements
938 where the pseudo-elements live inside their corresponding element,
939 declarations in ''::nth-fragment()'' pseudo-elements override
940 declarations in rules without the pseudo-element.
941 The relative priority within such declarations is determined
942 by normal cascading order (see [[!CSS21]]).
943 </p>
945 <p>
946 Styles specified on ''::nth-fragment()'' pseudo-elements
947 do affect inheritance to content within the <a>fragment box</a>.
948 In other words, the content within the <a>fragment box</a> must
949 inherit from the fragment box's style (i.e., the pseudo-element style)
950 rather than directly from the element.
951 This means that elements split between fragment boxes may
952 have different styles for different parts of the element.
953 </p>
955 <p class="issue">
956 This inheritance rule allows specifying styles indirectly
957 (by using explicit ''inherit'' or using default inheritance
958 on properties that don't apply to ''::first-letter'')
959 that can't be specified directly
960 (based on the rules in the next section).
961 This is a problem.
962 The restrictions that apply to styling inside fragments
963 should also apply to inheritance from fragments.
964 </p>
966 <div class="example">
967 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
968 <style>
969 .article {
970 continue: fragments;
971 }
972 .article::nth-fragment(1) {
973 font-size: 1.5em;
974 margin-bottom: 1em;
975 height: 4em;
976 }
977 .article::nth-fragment(2) {
978 margin-left: 5em;
979 margin-right: 2em;
980 }
981 </style>
982 <div class="article">
983 The <code>font-size</code> property<i>...</i>
984 </div></pre></td><td>
985 <div class="article-font-inherit-demo one">The <code>font-size</code> property<br>specified on the fragment<br>is inherited into the</div>
986 <div class="article-font-inherit-demo two">descendants of the fragment.<br>This means that inherited<br>properties can be used<br>reliably on a fragment, as in<br>this example.</div>
987 </td></tr></table>
988 </div>
990 <h4 id="style-in-fragments">Styling inside fragments</h4>
992 <p class="issue">
993 Should this apply to continue:fragments only,
994 or also to continue:paginate?
995 </p>
997 <p>
998 The ''::nth-fragment()'' pseudo-element
999 can also be used to style
1000 content inside of a <a>fragment box</a>.
1001 Unlike the ''::first-line'' and ''::first-letter'' pseudo-elements,
1002 the ''::nth-fragment()'' pseudo-element can be applied
1003 to parts of the selector other than the subject:
1004 in particular, it can match ancestors of the subject.
1005 However, the only CSS properties applied
1006 by rules with such selectors
1007 are those that apply
1008 to the ''::first-letter'' pseudo-element.
1009 </p>
1011 <p>
1012 To be more precise,
1013 when a rule's selector has ''::nth-fragment()'' pseudo-elements
1014 attached to parts of the selector other than the subject,
1015 the declarations in that rule apply to
1016 a fragment (or pseudo-element thereof) when:
1017 </p>
1018 <ol>
1019 <li>
1020 the declarations are for properties that apply to the
1021 ''::first-letter'' pseudo-element,
1022 </li>
1023 <li>
1024 the declarations would apply to
1025 that fragment (or pseudo-element thereof)
1026 had those ''::nth-fragment()'' pseudo-elements been removed,
1027 with a particular association between
1028 each sequence of simple selectors and the element it matched,
1029 and
1030 </li>
1031 <li>
1032 for each removed ''::nth-fragment()'' pseudo-element,
1033 the fragment lives within a <a>fragment box</a>
1034 of the element associated in that association
1035 with the selector that the pseudo-element was attached to,
1036 and whose index matches the pseudo-element.
1037 </li>
1038 </ol>
1040 <div class="example">
1041 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
1042 <style>
1043 .dark-columns {
1044 continue: fragments;
1045 width: 6em;
1046 height: 10em;
1047 float: left;
1048 margin-right: 1em;
1049 font: medium/1.25 Times New
1050 Roman, Times, serif;
1051 }
1052 .dark-columns::nth-fragment(1) {
1053 background: aqua; color: black;
1054 }
1055 .dark-columns::nth-fragment(1) :link {
1056 color: blue;
1057 }
1058 .dark-columns::nth-fragment(1) :visited {
1059 color: purple;
1060 }
1061 .dark-columns::nth-fragment(2) {
1062 background: navy; color: white;
1063 }
1064 .dark-columns::nth-fragment(2) :link {
1065 color: aqua;
1066 }
1067 .dark-columns::nth-fragment(2) :visited {
1068 color: fuchsia;
1069 }
1070 </style>
1071 <div class="dark-columns">
1072 <i>...</i>
1073 </div></pre></td><td>
1074 <div class="dark-columns-demo one">In this<br><a href="http://en.wiktionary.org/wiki/example">example</a>, the<br>text flows<br>from one<br>light-colored<br>fragment into<br>another<br>dark-colored</div>
1075 <div class="dark-columns-demo two">fragment. We<br>therefore want<br>different styles<br>for <a href="http://www.w3.org/Provider/Style/IntoContext.html">hyperlinks</a><br>in the different<br>fragments.</div>
1076 </td></tr></table>
1077 </div>
1080 <h3 id="max-lines">The 'max-lines' property</h3>
1082 <p>
1083 Authors may wish to style the opening lines of an element
1084 with different styles
1085 by putting those opening lines in a separate fragment.
1086 However, since it may be difficult to predict the exact height
1087 occupied by those lines
1088 in order to restrict the first fragment to that height,
1089 this specification introduces a 'max-lines' property
1090 that forces a fragment to break
1091 after a specified number of lines.
1092 This forces a break after the given number of lines
1093 contained within the element or its descendants,
1094 as long as those lines are in the same block formatting context.
1095 </p>
1097 <pre class=propdef>
1098 Name: max-lines
1099 Value: ''none'' | ''<integer>''
1100 Initial: ''none''
1101 Applies to: fragment boxes
1102 Inherited: no
1103 Animatable: as <a href="http://www.w3.org/TR/css3-transitions/#animatable-types">integer</a>
1104 Percentages: N/A
1105 Media: visual
1106 Computed value: specified value
1107 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
1108 </pre>
1110 <dl dfn-for="max-lines" dfn-type="value">
1111 <dt><dfn>none</dfn>
1112 <dd>
1113 <p>
1114 Breaks occur only as specified elsewhere.
1115 </p>
1116 </dd>
1118 <dt><dfn><<integer>></dfn>
1119 <dd>
1120 <p>
1121 In addition to any breaks specified elsewhere,
1122 a break is forced before any line that would exceed
1123 the given number of lines
1124 being placed inside the element
1125 (excluding lines that are in
1126 a different block formatting context from
1127 the block formatting context to which
1128 an unstyled child of the element would belong).
1129 </p>
1131 <p class="issue">
1132 If there are multiple boundaries between this line
1133 and the previous, where exactly (in terms of element
1134 boundaries) is the break forced?
1135 </p>
1137 <p>
1138 Only positive integers are accepted.
1139 Zero or negative integers are a parse error.
1140 </p>
1141 </dd>
1142 </dl>
1144 <p class="issue">Should this apply to fragment overflow only, or also
1145 to pagination?
1146 Given what we're doing with the continue property,
1147 it should actually apply to any fragmentainer.</p>
1149 Issue: having max-lines do nothing on regular elements is not ideal.
1150 When applied to non fragmentainers,
1151 it should probably cause 'continue' to compute to ''continue/discard''
1152 so that you only need to reach for one property rather than 2 to get
1153 that effect.
1155 <div class="example">
1156 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
1157 <style>
1158 .article {
1159 continue: fragments;
1160 }
1161 .article::first-letter {
1162 font-size: 2em;
1163 line-height: 0.9;
1164 }
1165 .article::nth-fragment(1) {
1166 font-size: 1.5em;
1167 max-lines: 3;
1168 }
1169 .article::nth-fragment(2) {
1170 column-count: 2;
1171 }
1172 </style>
1173 <div class="article">
1174 <i>...</i>
1175 </div></pre></td><td>
1176 <div class="article-max-lines-demo one">The max-lines property allows<br>authors to use a larger font for the first<br>few lines of an article. Without the</div>
1177 <div class="article-max-lines-demo two">max-lines property, authors<br>might have to use the<br>'height' property instead, but<br>that would leave a slight gap<br>if the author miscalculated<br>how much height a given<br>number of lines would<br>occupy (which might be</div>
1178 <div class="article-max-lines-demo three">particularly hard if the author<br>didn't know what text would<br>be filling the space, exactly<br>what font would be used, or<br>exactly which platform's font<br>rendering would be used to<br>display the font).</div>
1179 </td></tr></table>
1180 </div>
1182 <h2 id="static-media">Overflow in static media</h2>
1184 <p class="issue">
1185 This specification should define useful behavior
1186 for all values of 'overflow' and 'continue'
1187 in static media (such as print).
1188 Current implementation behavior is quite poor and
1189 produces unexpected results when authors have not considered
1190 what will happen when
1191 the content they produce for interactive media
1192 is printed.
1193 </p>
1195 <h2 class=no-num id="acknowledgments">
1196 Acknowledgments</h2>
1198 <p>
1199 Thanks especially to the feedback from
1200 Rossen Atanassov,
1201 Bert Bos,
1202 Tantek Ãelik,
1203 John Daggett,
1204 fantasai,
1205 Daniel Glazman,
1206 Vincent Hardy,
1207 Håkon Wium Lie,
1208 Peter Linss,
1209 Robert O'Callahan,
1210 Florian Rivoal,
1211 Alan Stearns,
1212 Steve Zilles,
1213 and all the rest of the
1214 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.
1215 </p>