Mon, 22 May 2017 18:25:40 +0900
[css-overflow] Synchronize level 3 and 4
Remove from level 4 parts that are maintained in level 3,
and from level 3 an issue that has been solved in level 4.
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, 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 </pre>
15 <pre class="link-defaults">
16 type: dfn; spec:css-multicol-1; text:overflow column
17 </pre>
18 <pre class="anchors">
19 url: https://drafts.csswg.org/selectors-3/#subject; type: dfn; text: subject;
20 </pre>
21 <style>
22 table.source-demo-pair {
23 width: 100%;
24 }
26 .in-cards-demo {
27 width: 13em;
28 height: 8em;
30 padding: 4px;
31 border: medium solid blue;
32 margin: 6px;
34 font: medium/1.3 Times New Roman, Times, serif;
35 white-space: nowrap;
36 }
38 .bouncy-columns-demo {
39 width: 6em;
40 height: 10em;
41 float: left;
42 margin: 1em;
43 font: medium/1.25 Times New Roman, Times, serif;
44 white-space: nowrap;
45 }
46 .bouncy-columns-demo.one {
47 background: aqua; color: black;
48 transform: rotate(-3deg);
49 }
50 .bouncy-columns-demo.two {
51 background: yellow; color: black;
52 transform: rotate(3deg);
53 }
55 .article-font-inherit-demo {
56 font: 1em/1.25 Times New Roman, Times, serif;
57 white-space: nowrap;
58 }
59 .article-font-inherit-demo.one {
60 width: 12em;
61 font-size: 1.5em;
62 margin-bottom: 1em;
63 height: 4em;
64 }
65 .article-font-inherit-demo.two {
66 width: 11em;
67 margin-left: 5em;
68 margin-right: 2em;
69 }
71 .dark-columns-demo {
72 width: 6em;
73 height: 10em;
74 float: left;
75 margin-right: 1em;
76 font: medium/1.25 Times New Roman, Times, serif;
77 white-space: nowrap;
78 }
79 .dark-columns-demo.one {
80 background: aqua; color: black;
81 }
82 .dark-columns-demo.one :link {
83 color: blue;
84 }
85 .dark-columns-demo.one :visited {
86 color: purple;
87 }
88 .dark-columns-demo.two {
89 background: navy; color: white;
90 }
91 .dark-columns-demo.two :link {
92 color: aqua;
93 }
94 .dark-columns-demo.two :visited {
95 color: fuchsia;
96 }
98 .article-max-lines-demo {
99 font: 1em/1.25 Times New Roman, Times, serif;
100 white-space: nowrap;
101 }
102 .article-max-lines-demo.one::first-letter {
103 font-size: 2em;
104 line-height: 0.9;
105 }
106 .article-max-lines-demo.one {
107 font-size: 1.5em;
108 width: 16em;
109 }
110 .article-max-lines-demo.two {
111 width: 11.5em;
112 float: left; margin-right: 1em;
113 }
114 .article-max-lines-demo.three {
115 width: 11.5em;
116 float: left;
117 }
118 </style>
120 <h2 id="intro">
121 Introduction</h2>
123 Note: At the time of writing, [[CSS-OVERFLOW-3]] is not completely finalized yet.
124 To avoid accidental divergences and maintenance overhead,
125 This specification is written as a delta specification over css-overflow Level 3.
126 Once the level 3 specification is final,
127 its content will be integrated into this specification,
128 which will then replace it.
129 Until then, this specification only contains additions and extensions to level 3.
131 <p>
132 In CSS Level 1 [[CSS1]], placing more content than would fit
133 inside an element with a specified size
134 was generally an authoring error.
135 Doing so caused the content to extend
136 outside the bounds of the element,
137 which would likely cause
138 that content to overlap with other elements.
139 </p>
141 <p>
142 CSS Level 2 [[CSS21]] introduced the 'overflow' property,
143 which allows authors to have overflow be handled by scrolling,
144 which means it is no longer an authoring error.
145 It also allows authors to specify
146 that overflow is handled by clipping,
147 which makes sense when the author's intent
148 is that the content not be shown.
149 This was further refined in the CSS Overflow Module Level 3 [[CSS-OVERFLOW-3]].
150 </p>
152 <p>
153 However, scrolling is not the only way
154 to present large amounts of content,
155 and may even not be the optimal way.
156 After all, the codex replaced the scroll
157 as the common format for large written works
158 because of its advantages.
159 </p>
161 <p>
162 This specification introduces
163 a mechanism for Web pages to specify
164 that an element of a page should handle overflow
165 through pagination rather than through scrolling.
166 </p>
168 <p>
169 This specification also extends the concept of overflow
170 in another direction.
171 Instead of requiring that authors specify a single area
172 into which the content of an element must flow,
173 this specification allows authors to specify multiple fragments,
174 each with their own dimensions and styles,
175 so that the content of the element can flow from one to the next,
176 using as many as needed to place the content without overflowing.
177 </p>
179 <p>
180 In both of these cases, implementations must
181 break the content in the block-progression dimension.
182 Implementations must do this is described
183 in the CSS Fragmentation Module [[!CSS3-BREAK]].
184 </p>
186 <h2 id="overflow-concepts">Types of overflow</h2>
188 Issue: copy level 3 content when final
191 <h2 id="overflow-properties">Overflow properties</h2>
193 Issue: copy level 3 content when final
196 <h2 id="scollbar-gutter-property">
197 Reserving space for the scrollbar: the 'scrollbar-gutter' property</h2>
199 The space between the inner border edge and the outer padding edge
200 which user agents may reserve to display the scrollbar
201 is called the <dfn>scrollbar gutter</dfn>.
203 The 'scrollbar-gutter' property gives control to the author
204 over the presence of <a>scrollbar gutters</a>
205 separately from the ability to control the presence of scrollbars
206 provided by the 'overflow' property.
208 <pre class="propdef">
209 Name: scrollbar-gutter
210 Value: ''auto'' | [ ''stable'' | ''always'' ] && ''both''? && ''force''?
211 Initial: auto
212 Inherited: yes
213 Computed value: specified value
214 </pre>
216 This property affects the presence of <a>scrollbar gutters</a>
217 placed at the <a>inline start</a> edge or <a>inline end</a> edge of the box.
219 The presence of a <a>scrollbar gutter</a>
220 at the <a>block start</a> edge and <a>block end</a> edge of the box
221 cannot be controlled in this level,
222 and is determined the same way as the presence of <a>scrollbar gutters</a>
223 placed at the <a>inline start</a> edge or <a>inline end</a> edge of the box
224 when 'scrollbar-gutter' is ''scrollbar-gutter/auto''.
226 Scrollbars which by default are placed over the content box
227 and do not cause <a>scrollbar gutters</a> to be created
228 are called <dfn>overlay scrollbars</dfn>.
229 Such scrollbars are usually partially transparent, revealing the content behind them if any.
230 Their appearance and size may vary
231 based on whether and how the user is interacting with them.
233 Scrollbars which are always placed in a <a>scrollbar gutter</a>,
234 consuming space when present,
235 are called <dfn>classic scrollbars</dfn>.
236 Such scrollbars are usually opaque.
238 Whether <a>classic scrollbars</a> or <a>overlay scrollbars</a> are used is UA defined.
240 The appearance and size of the scrollbar is UA defined.
242 Whether scrollbars appear on the start or end edge of the box is UA defined.
244 For <a>classic scrollbars</a>,
245 the width of the <a>scrollbar gutter</a> is the same as the width of the scrollbar.
246 For <a>overlay scrollbars</a>,
247 the width of the <a>scrollbar gutter</a> is UA defined.
248 However, it must not be 0,
249 and it must not change based on user interactions with the page or the scrollbar
250 even if the scrollbar itself changes.
251 Also, it must be the same for all elements in the page.
253 The values of this property have the following meaning:
255 <dl dfn-for="scrollbar-gutter">
256 <dt><dfn>''scrollbar-gutter/auto''</dfn>
257 <dd><a>Classic scrollbars</a> consume space by creating a <a>scrollbar gutter</a>
258 when 'overflow' is ''overflow/scroll',
259 or when 'overflow' is ''overflow/auto'' and the box is overflowing.
260 <a>Overlay scrollbars</a> do not consume space.
262 <dt><dfn>''stable''</dfn>
263 <dd>The <a>scrollbar gutter</a> is present when
264 'overflow' is ''overflow/scroll'' or ''overflow/auto''
265 and the scrollbar is a <a>classic scrollbar</a>
266 even if the box is not overflowing,
267 but not when the scrollbar is an <a>overlay scrollbar</a>.
269 <dt><dfn>''always''</dfn>
270 <dd>The <a>scrollbar gutter</a> is always present when
271 'overflow' is ''overflow/scroll'' or ''overflow/auto'',
272 regardless of the type of scrollbar or
273 of whether the box is overflowing.
275 <dt><dfn>''both''</dfn>
276 <dd>If a <a>scrollbar gutter</a> would be present
277 on one of the inline start edge or the inline end edge of the box,
278 another <a>scrollbar gutter</a> must be present on the opposite edge as well.
280 <dt><dfn>''force''</dfn>
281 <dd>When the ''scrollbar-gutter/force'' keyword is present
282 ''scrollbar-gutter/stable'' and ''scrollbar-gutter/always'' take effect
283 when 'overflow' is ''overflow/visible'', ''overflow/hidden'' or ''overflow/clip''
284 in addition ''overflow/auto'' or ''overflow/scroll''.
285 This does not cause a scrollbar to be displayed, only a <a>scrollbar gutter</a>.
286 </dl>
288 When the <a>scrollbar gutter</a> is present but the scrollbar is not,
289 or the scrollbar is transparent or otherwise does not fully obscure the <a>scrollbar gutter</a>,
290 the background of the <a>scrollbar gutter</a> must be painted as an extension of the padding.
292 <div class=note>
293 Note: The following table summarises the interaction of 'overflow' and 'scrollbar-gutter',
294 showing in which case space is reserved for the <a>scrollbar gutter</a>.
295 In this table, âGâ represents cases where space is reserved for the <a>scrollbar gutter</a>,
296 âf?â cases where space is reserved for the <a>scrollbar gutter</a>
297 if ''scrollbar-gutter/force'' was specified,
298 and empty cells cases where the no space is reserved.
300 <table class=data>
301 <thead>
302 <tr>
303 <td>
304 <td>
305 <th colspan=2>Classic scrollbars
306 <th colspan=2>Overlay scrollbars
307 <tr>
308 <th>'overflow'
309 <th>'scrollbar-gutter'
310 <th>Overflowing
311 <th>Not overflowing
312 <th>Overflowing
313 <th>Not overflowing
314 </thead>
315 <tr>
316 <th rowspan=3>'overflow/scroll'
317 <th>''scrollbar-gutter/auto''
318 <td>G
319 <td>G
320 <td>
321 <td>
322 <tr>
323 <th>''scrollbar-gutter/stable''
324 <td>G
325 <td>G
326 <td>
327 <td>
328 <tr>
329 <th>''scrollbar-gutter/always''
330 <td>G
331 <td>G
332 <td>G
333 <td>G
334 <tr>
335 <th rowspan=3>''overflow/auto''
336 <th>''scrollbar-gutter/auto''
337 <td>G
338 <td>
339 <td>
340 <td>
341 <tr>
342 <th>''scrollbar-gutter/stable''
343 <td>G
344 <td>G
345 <td>
346 <td>
347 <tr>
348 <th>''scrollbar-gutter/always''
349 <td>G
350 <td>G
351 <td>G
352 <td>G
353 <tr>
354 <th rowspan=3>''overflow/visible'', ''overflow/hidden'', ''overflow/clip''
355 <th>''scrollbar-gutter/auto''
356 <td>
357 <td>
358 <td>
359 <td>
360 <tr>
361 <th>''scrollbar-gutter/stable''
362 <td>f?
363 <td>f?
364 <td>
365 <td>
366 <tr>
367 <th>''scrollbar-gutter/always''
368 <td>f?
369 <td>f?
370 <td>f?
371 <td>f?
372 </table>
373 </div>
375 <h2 id="fragmentation">Fragmentation of overflow</h2>
377 The 'continue' property gives authors the ability
378 to request that content that does not fit inside an element
379 be fragmented (in the sense of [[!CSS3-BREAK]]),
380 and provides alternatives
381 for where the remaining content should continue.
383 Notably, this property explains traditional pagination,
384 and extends it further.
386 <pre class=propdef>
387 Name: continue
388 Value: ''auto'' | ''overflow'' | ''paginate'' | ''fragments'' | ''discard''
389 Initial: auto
390 Applies to: block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
391 Inherited: no
392 Percentages: N/A
393 Media: visual
394 Computed value: see below
395 Animatable: no
396 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
397 </pre>
399 Issue: The naming of this property and its values is preliminary.
400 This was initially proposed as
401 "fragmentation: auto | none | break | clone | page"
402 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>,
403 and there is not yet wide agreement as to which naming is better.
405 Issue: This property is meant to generalize and replace 'region-fragment'.
406 Once it is sufficiently stable in this specification,
407 'region-fragment' should be removed from the regions specification in favor of this.
409 Note: ''continue: fragments'' replaces "overflow:fragments"
410 from earlier versions of this specification,
411 while ''continue: paginate'' replaces "overflow: paged-x | paged-y | paged-x-controls | paged-y-controls"
413 <dl dfn-for="continue" dfn-type="value">
414 <dt><dfn>auto</dfn>
415 <dd>''continue/auto'' may only occur as a computed value
416 if the element is a <a spec="css-regions">CSS Region</a>
417 other than the last one in a <a spec="css-regions">region chain</a>.
418 Content that doesn't fit is pushed to the next region of the chain.
420 In all other cases, ''continue/auto'' computes to one of the other values.
422 <dt><dfn>overflow</dfn>
423 <dd>Content that doesn't fit overflows, according to the 'overflow' property
425 <dt><dfn>discard</dfn>
426 <dd>Content that doesn't fit is discarded at a fragmentation break
428 Note: generalized from region-fragment: break; on the last region of a region chain
430 Issue: When the element isn't a <a spec="css-break">fragmentation container</a> already,
431 should this work by turning it directly into one,
432 or by creating a <a>fragment box</a> inside it like ''continue/fragments'' does?
434 <dt><dfn>paginate</dfn>
435 <dd>Content that doesn't fit paginates.
436 This creates a paginated view inside the element
437 similar to the way that 'overflow: scroll' creates a scrollable view.
439 See <a href="#paginated-overflow">paginated overflow</a>
441 Note: Print is effectively "continue: paginate" on the root.
442 <dt><dfn>fragments</dfn>
443 <dd>content that doesn't fit causes the element to copy itself and continue laying out.
445 See <a href="#fragment-overflow">fragment overflow</a>.
446 </dl>
448 The computed value of the 'continue' for a given element or pseudo element is determined as follow:
449 <ol>
450 <li>If the specified value is ''continue/auto''
451 <ol>
452 <li>On a <a spec="css-regions">CSS Region</a> other than the last one in a <a spec="css-regions">region chain</a>,
453 the computed value is ''continue/auto''
454 <li>On a page
455 the computed value is ''continue/paginate''
456 <li>On a <a>fragment box</a>
457 the computed value is ''continue/fragments''
458 <li>Otherwise, the computed value is ''continue/overflow''
459 </ol>
460 <li>If the specified value is ''continue/framgents''
461 <ol>
462 <li>On a page
463 the computed value is ''continue/paginate''
464 <li>Otherwise, the computed value is the specified value
465 </ol>
466 <li>In all other cases, the computed value is the specified value
467 </ol>
469 Issue: If we introduce a pseudo element that can select columns in a multicol,
470 we would need to specify that auto computes to auto on it,
471 or introduce a new value and have auto compute to that
472 (but what would that value compute to on things that aren't columns?).
474 Note: For background discussions leading to this property, see these threads:
475 <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
476 <a href="https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html">proposal for a fragmentation property</a>
478 <h2 id="paginated-overflow">Paginated overflow</h2>
480 This section introduces and defines the meaning of the ''continue/paginate'' value of the 'continue' property.
482 Issue: Write this section
484 Issue: Pages should be possible to style with @page rules. How does that work for nested pages?
486 <div class="issue">
487 Should traditional pagination (e.g. when printing)
488 be expressed through some magic in the computed value of ''continue/auto'',
489 or by inserting this in the UA stylesheet:
490 <pre><code class="lang-css">
491 @media (overflow-block: paged), (overflow-block: optional-paged) {
492 :root {
493 continue: paginate;
494 }
495 }
496 </code></pre>
497 </div>
499 Issue: Traditional pagination (e.g. when printing) assumes that
500 :root is contained in the page box,
501 rather than having the page box be a pseudo element child of :root.
502 Can we work around that using something similar to fragment boxes?
503 Or maybe by having a fragment box (reproducing :root) inside a page box inside :root?
505 Issue: How does the page box model work when it is a child of a regular css box?
507 Issue: The initial proposal in [[CSS3GCPM]] and implemantation from Opera
508 used 4 values instead of ''continue/paginate'':
509 "paged-x | paged-y | paged-x-controls | paged-y-controls".
510 Should this property also include these values,
511 or are they better handled as separate properties?
512 (e.g.: "pagination-layout: auto | horizontal | vertical", "pagination-controls: auto | none")
514 Issue: Ability to display N pages at once
515 rather than just one page at once?
516 Could this be a value of "pagination-layout", such as:
517 "pagination-layout: horizontal 2;"
519 Issue: Brad Kemper has proposed a model for combining pagination and
520 fragment overflow, which also deals with displaying multiple pages.
521 <a href="http://www.w3.org/mid/[email protected]">http://www.w3.org/mid/[email protected]</a>
523 <p class="issue">
524 The current implementation of paginated overflow uses
525 the 'overflow'/'overflow-x'/'overflow-y' properties
526 rather than the 'overflow-style' property as proposed
527 in the [[CSS3GCPM]] draft
528 (which also matches the [[CSS3-MARQUEE]] proposal).
529 or the 'continue' property as described here.
530 </p>
532 <h2 id="fragment-overflow">Fragment overflow</h2>
534 This section introduces and defines the meaning of
535 the ''continue/fragments'' value of the 'continue' property.
537 <p>
538 When the computed value of 'continue' for an element is ''continue/fragments'',
539 and implementations would otherwise have created a box for the element,
540 then implementations must create a sequence of <dfn>fragment box</dfn>es
541 for that element.
542 (It is possible for an element with ''continue: fragments''
543 to generate only one <a>fragment box</a>.
544 However, if an element's computed 'continue' is not ''continue/fragments'',
545 then its box is not a <a>fragment box</a>.)
546 Every <a>fragment box</a> is a fragmentation container,
547 and any overflow
548 that would cause that fragmentation container to fragment
549 causes another <a>fragment box</a> created as a next sibling
550 of the previous one.
551 <span class="issue">Or is it as though it's a next sibling of
552 the element? Need to figure out exactly how this interacts with
553 other box-level fixup.</span>
554 Additionally, if the <a>fragment box</a> is also
555 a multi-column box (as defined in [[!CSS3COL]]
556 <span class="issue">though it defines <i>multi-column element</i></span>)
557 any content that would lead to the creation of <a>overflow columns</a> [[!CSS3COL]]
558 instead is flown into an additional fragment box.
559 However, fragment boxes may themselves be broken
560 (due to fragmentation in a fragmentation context outside of them,
561 such as pages, columns, or other fragment boxes);
562 such breaking leads to fragments of the same fragment box
563 rather than multiple fragment boxes.
564 (This matters because fragment boxes may be styled by their index;
565 such breaking leads to multiple fragments of a fragment box
566 with a single index.
567 This design choice is so that
568 breaking a fragment box across pages does not break
569 the association of indices to particular pieces of content.)
570 <span class="issue">Should a forced break that breaks to
571 an outer fragmentation context cause a new fragment of a single
572 fragment box or a new fragment box?</span>
573 <span class="issue">Should we find a term other than
574 <a>fragment box</a> here to make this a little less confusing?</span>
575 </p>
577 <p class="issue">
578 What if we want to be able to style the pieces of an element
579 split within another type of fragmentation context?
580 These rules prevent ever using ''::nth-fragment()'' for that,
581 despite that the name seems the most logical name for such a feature.
582 </p>
584 <div class="example">
585 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
586 <title>Breaking content into
587 equal-sized cards</title>
588 <style>
589 .in-cards {
590 continue: fragments;
592 width: 13em;
593 height: 8em;
595 padding: 4px;
596 border: medium solid blue;
597 margin: 6px;
599 font: medium/1.3 Times New
600 Roman, Times, serif;
601 }
602 </style>
603 <div class="in-cards">
604 In this example, the text in the div
605 is broken into a series of cards.
606 These cards all have the same style.
607 The presence of enough content to
608 overflow one of the cards causes
609 another one to be created. The second
610 card is created just like it's the
611 next sibling of the first.
612 </div></pre></td><td>
613 <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>
614 <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>
615 </td></tr></table>
616 </div>
618 <p class="issue">
619 We should specify that ''continue: fragments'' does not apply
620 to at least some table parts,
621 and perhaps other elements as well.
622 We need to determine exactly which ones.
623 </p>
625 <p class="issue">
626 This specification needs to say which type of
627 fragmentation context is created
628 so that it's clear which values of the 'break-*' properties
629 cause breaks within this context.
630 We probably want ''break-*: region'' to apply.
631 </p>
633 <p class="issue">
634 This specification needs a processing model
635 that will apply in cases where the layout containing the
636 fragments has characteristics that use the intrinsic size of the fragments
637 to change the amount of space available for them,
638 such as [[CSS3-GRID-LAYOUT]].
639 There has already been some work on such a processing model
640 in [[CSS3-REGIONS]],
641 and the work done on a model there,
642 and the editors of that specification,
643 should inform what happens in this specification.
644 </p>
646 <h3 id="fragment-styling">Fragment styling</h3>
648 <h4 id="fragment-pseudo-element">The ::nth-fragment() pseudo-element</h4>
650 <p>
651 The <dfn selector>::nth-fragment()</dfn> pseudo-element
652 is a pseudo-element
653 that describes some of the <a>fragment box</a>es generated by an element.
654 The argument to the pseudo-element takes the same syntax
655 as the argument to the :nth-child() pseudo-class
656 defined in [[!SELECT]], and has the same meaning
657 except that the number is relative to
658 <a>fragment box</a>es generated by the element
659 instead of siblings of the element.
660 </p>
662 <p class="note">
663 Selectors that allow addressing fragments
664 by counting from the end rather than the start
665 are intentionally not provided.
666 Such selectors would interfere with determining
667 the number of fragments.
668 </p>
670 <p class="issue">
671 Depending on future discussions,
672 this ''::nth-fragment(<var>an+b</var>)'' syntax
673 may be replaced with
674 the new ''::fragment:nth(<var>an+b</var>)'' syntax.
675 </p>
677 <h4 id="style-of-fragments">Styling of fragments</h4>
679 <p class="issue">
680 Should this apply to continue:fragments only,
681 or also to continue:paginate?
682 (If it applies,
683 then stricter property restrictions would be needed
684 for continue:paginate.)
685 </p>
687 <p>
688 In the absence of rules with ''::nth-fragment()'' pseudo-elements,
689 the computed style for each <a>fragment box</a>
690 is the computed style for the element
691 for which the <a>fragment box</a> was created.
692 However, the style for a <a>fragment box</a> is also influenced
693 by rules whose selector's <a>subject</a> [[!SELECT]]
694 has an ''::nth-fragment()'' pseudo-element,
695 if the 1-based number of the <a>fragment box</a> matches
696 that ''::nth-fragment()'' pseudo-element
697 and the selector (excluding the ''::nth-fragment()'' pseudo-element)
698 matches the element generating the fragments.
699 </p>
701 <p>
702 When determining the style of the <a>fragment box</a>,
703 these rules that match the fragment pseudo-element
704 cascade together with the rules that match the element,
705 with the fragment pseudo-element adding the specificity
706 of a pseudo-class to the specificity calculation.
707 <span class="issue">Does this need to be specified in
708 the cascading module as well?</span>
709 </p>
711 <div class="example">
712 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
713 <style>
714 .bouncy-columns {
715 continue: fragments;
716 width: 6em;
717 height: 10em;
718 float: left;
719 margin: 1em;
720 font: medium/1.25 Times New
721 Roman, Times, serif;
722 }
723 .bouncy-columns::nth-fragment(1) {
724 background: aqua; color: black;
725 transform: rotate(-3deg);
726 }
727 .bouncy-columns::nth-fragment(2) {
728 background: yellow; color: black;
729 transform: rotate(3deg);
730 }
731 </style>
732 <div class="bouncy-columns">
733 <i>...</i>
734 </div></pre></td><td>
735 <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>
736 <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>
737 <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>
738 </td></tr></table>
739 </div>
741 <p>
742 Styling an ''::nth-fragment()'' pseudo-element with the 'continue'
743 property does take effect;
744 if a <a>fragment box</a> has a
745 computed value of 'continue' other than ''fragments''
746 then that fragment box is the last fragment.
747 However, overriding 'continue' on the first fragment
748 does not cause the <a>fragment box</a> not to exist;
749 whether there are fragment boxes at all is determined by
750 the computed value of overflow for the element.
751 </p>
753 <p>
754 Styling an ''::nth-fragment()'' pseudo-element with the 'content'
755 property has no effect;
756 the computed value of 'content' for the fragment box
757 remains the same as the computed value of content for the element.
758 </p>
760 <p>
761 Specifying ''display: none'' for a <a>fragment box</a> causes
762 the fragment box with that index not to be generated.
763 However, in terms of the indices
764 used for matching ''::nth-fragment()'' pseudo-elements
765 of later fragment boxes,
766 it still counts as though it was generated.
767 However, since it is not generated, it does not contain any content.
768 </p>
770 <p>
771 Specifying other values of 'display', 'position',
772 or 'float' is permitted, but is not allowed to change
773 the computed value of 'display-inside'.
774 (Since 'continue' only
775 applies to block containers, flex containers, and grid containers
776 the computed value of 'display-inside' is always
777 ''display-inside/block'', ''display-inside/flex'', or
778 ''display-inside/grid''.
779 <span class="issue">Need to specify exactly how this works,
780 but it depends on
781 having 'display-inside' and 'display-outside' specified.</span>
782 </p>
784 <p>
785 To match the model for other pseudo-elements
786 where the pseudo-elements live inside their corresponding element,
787 declarations in ''::nth-fragment()'' pseudo-elements override
788 declarations in rules without the pseudo-element.
789 The relative priority within such declarations is determined
790 by normal cascading order (see [[!CSS21]]).
791 </p>
793 <p>
794 Styles specified on ''::nth-fragment()'' pseudo-elements
795 do affect inheritance to content within the <a>fragment box</a>.
796 In other words, the content within the <a>fragment box</a> must
797 inherit from the fragment box's style (i.e., the pseudo-element style)
798 rather than directly from the element.
799 This means that elements split between fragment boxes may
800 have different styles for different parts of the element.
801 </p>
803 <p class="issue">
804 This inheritance rule allows specifying styles indirectly
805 (by using explicit ''inherit'' or using default inheritance
806 on properties that don't apply to ''::first-letter'')
807 that can't be specified directly
808 (based on the rules in the next section).
809 This is a problem.
810 The restrictions that apply to styling inside fragments
811 should also apply to inheritance from fragments.
812 </p>
814 <div class="example">
815 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
816 <style>
817 .article {
818 continue: fragments;
819 }
820 .article::nth-fragment(1) {
821 font-size: 1.5em;
822 margin-bottom: 1em;
823 height: 4em;
824 }
825 .article::nth-fragment(2) {
826 margin-left: 5em;
827 margin-right: 2em;
828 }
829 </style>
830 <div class="article">
831 The <code>font-size</code> property<i>...</i>
832 </div></pre></td><td>
833 <div class="article-font-inherit-demo one">The <code>font-size</code> property<br>specified on the fragment<br>is inherited into the</div>
834 <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>
835 </td></tr></table>
836 </div>
838 <h4 id="style-in-fragments">Styling inside fragments</h4>
840 <p class="issue">
841 Should this apply to continue:fragments only,
842 or also to continue:paginate?
843 </p>
845 <p>
846 The ''::nth-fragment()'' pseudo-element
847 can also be used to style
848 content inside of a <a>fragment box</a>.
849 Unlike the ''::first-line'' and ''::first-letter'' pseudo-elements,
850 the ''::nth-fragment()'' pseudo-element can be applied
851 to parts of the selector other than the subject:
852 in particular, it can match ancestors of the subject.
853 However, the only CSS properties applied
854 by rules with such selectors
855 are those that apply
856 to the ''::first-letter'' pseudo-element.
857 </p>
859 <p>
860 To be more precise,
861 when a rule's selector has ''::nth-fragment()'' pseudo-elements
862 attached to parts of the selector other than the subject,
863 the declarations in that rule apply to
864 a fragment (or pseudo-element thereof) when:
865 </p>
866 <ol>
867 <li>
868 the declarations are for properties that apply to the
869 ''::first-letter'' pseudo-element,
870 </li>
871 <li>
872 the declarations would apply to
873 that fragment (or pseudo-element thereof)
874 had those ''::nth-fragment()'' pseudo-elements been removed,
875 with a particular association between
876 each sequence of simple selectors and the element it matched,
877 and
878 </li>
879 <li>
880 for each removed ''::nth-fragment()'' pseudo-element,
881 the fragment lives within a <a>fragment box</a>
882 of the element associated in that association
883 with the selector that the pseudo-element was attached to,
884 and whose index matches the pseudo-element.
885 </li>
886 </ol>
888 <div class="example">
889 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
890 <style>
891 .dark-columns {
892 continue: fragments;
893 width: 6em;
894 height: 10em;
895 float: left;
896 margin-right: 1em;
897 font: medium/1.25 Times New
898 Roman, Times, serif;
899 }
900 .dark-columns::nth-fragment(1) {
901 background: aqua; color: black;
902 }
903 .dark-columns::nth-fragment(1) :link {
904 color: blue;
905 }
906 .dark-columns::nth-fragment(1) :visited {
907 color: purple;
908 }
909 .dark-columns::nth-fragment(2) {
910 background: navy; color: white;
911 }
912 .dark-columns::nth-fragment(2) :link {
913 color: aqua;
914 }
915 .dark-columns::nth-fragment(2) :visited {
916 color: fuchsia;
917 }
918 </style>
919 <div class="dark-columns">
920 <i>...</i>
921 </div></pre></td><td>
922 <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>
923 <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>
924 </td></tr></table>
925 </div>
928 <h3 id="max-lines">The 'max-lines' property</h3>
930 <p>
931 Authors may wish to style the opening lines of an element
932 with different styles
933 by putting those opening lines in a separate fragment.
934 However, since it may be difficult to predict the exact height
935 occupied by those lines
936 in order to restrict the first fragment to that height,
937 this specification introduces a 'max-lines' property
938 that forces a fragment to break
939 after a specified number of lines.
940 This forces a break after the given number of lines
941 contained within the element or its descendants,
942 as long as those lines are in the same block formatting context.
943 </p>
945 <pre class=propdef>
946 Name: max-lines
947 Value: ''none'' | ''<integer>''
948 Initial: ''none''
949 Applies to: fragment boxes
950 Inherited: no
951 Animatable: as <a href="https://www.w3.org/TR/css3-transitions/#animatable-types">integer</a>
952 Percentages: N/A
953 Media: visual
954 Computed value: specified value
955 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
956 </pre>
958 <dl dfn-for="max-lines" dfn-type="value">
959 <dt><dfn>none</dfn>
960 <dd>
961 <p>
962 Breaks occur only as specified elsewhere.
963 </p>
964 </dd>
966 <dt><dfn><<integer>></dfn>
967 <dd>
968 <p>
969 In addition to any breaks specified elsewhere,
970 a break is forced before any line that would exceed
971 the given number of lines
972 being placed inside the element
973 (excluding lines that are in
974 a different block formatting context from
975 the block formatting context to which
976 an unstyled child of the element would belong).
977 </p>
979 <p class="issue">
980 If there are multiple boundaries between this line
981 and the previous, where exactly (in terms of element
982 boundaries) is the break forced?
983 </p>
985 <p>
986 Only positive integers are accepted.
987 Zero or negative integers are a parse error.
988 </p>
989 </dd>
990 </dl>
992 <p class="issue">Should this apply to fragment overflow only, or also
993 to pagination?
994 Given what we're doing with the continue property,
995 it should actually apply to any fragmentainer.</p>
997 Issue: having max-lines do nothing on regular elements is not ideal.
998 When applied to non fragmentainers,
999 it should probably cause 'continue' to compute to ''continue/discard''
1000 so that you only need to reach for one property rather than 2 to get
1001 that effect.
1003 <div class="example">
1004 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
1005 <style>
1006 .article {
1007 continue: fragments;
1008 }
1009 .article::first-letter {
1010 font-size: 2em;
1011 line-height: 0.9;
1012 }
1013 .article::nth-fragment(1) {
1014 font-size: 1.5em;
1015 max-lines: 3;
1016 }
1017 .article::nth-fragment(2) {
1018 column-count: 2;
1019 }
1020 </style>
1021 <div class="article">
1022 <i>...</i>
1023 </div></pre></td><td>
1024 <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>
1025 <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>
1026 <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>
1027 </td></tr></table>
1028 </div>
1030 <h2 id="changes" class="no-num">
1031 Changes</h2>
1032 <h3 id="changes-l3">
1033 Changes Since Level 3</h3>
1035 The following changes were made to this specification since the
1036 <a href="https://drafts.csswg.org/css-overflow-3/">CSS Overflow Module Level 3</a>:
1038 <ul>
1039 <li>The Fragmentation of overflow, Paginated overflow, and Fragment overflow sections and subsections have been removed form Level 3 and moved to Level 4.
1040 <li>The 'scrollbar-gutter' property has been added.
1041 </ul>
1043 <h2 class=no-num id="acknowledgments">
1044 Acknowledgments</h2>
1046 <p>
1047 Thanks especially to the feedback from
1048 Rossen Atanassov,
1049 Bert Bos,
1050 Tantek Ãelik,
1051 John Daggett,
1052 fantasai,
1053 Daniel Glazman,
1054 Vincent Hardy,
1055 Håkon Wium Lie,
1056 Peter Linss,
1057 Robert O'Callahan,
1058 Florian Rivoal,
1059 Alan Stearns,
1060 Steve Zilles,
1061 and all the rest of the
1062 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.