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