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