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