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