Tue, 27 Jan 2015 15:59:53 -0800
[css-overflow] Write ::first-letter with 2 colons in one place it wasn't.
1 <h1>CSS Overflow Module Level 3</h1>
2 <pre class="metadata">
3 Status: ED
4 ED: http://dev.w3.org/csswg/css-overflow/
5 Shortname: css-overflow
6 Group: csswg
7 Level: 1
8 TR: http://www.w3.org/TR/css-overflow-3/
9 Previous version: http://www.w3.org/TR/2013/WD-css-overflow-3-20130418/
10 Editor: L. David Baron, Mozilla, http://dbaron.org/
11 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.
12 Status Text: The following features are at risk: …
13 !Change Log: <a href="https://dvcs.w3.org/hg/csswg/log/tip/css-overflow/Overview.bs">from 27 January 2015 to the present</a>
14 !Change Log: <a href="https://dvcs.w3.org/hg/csswg/log/tip/css-overflow/Overview.src.html">from 28 March 2013 to 27 January 2015</a>
15 !Change Log: <a href="https://dvcs.w3.org/hg/csswg/log/tip/css3-overflow/Overview.src.html">from 31 July 2012 to 27 March 2013</a>
16 </pre>
17 <pre class="link-defaults">
18 spec:css-transforms-1; type:property; text:transform-style
19 </pre>
20 <!-- FIXME: the break-* link doesn't actually work! -->
21 <pre class="anchors">
22 url: http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#the-overflow-style; type: property; text: overflow-style;
23 url: http://dev.w3.org/csswg/css-break/#breaking-controls; type: property; text: break-*;
24 url: http://dev.w3.org/csswg/css-multicol/#overflow-columns; type: dfn; text: overflow columns;
25 url: http://dev.w3.org/csswg/selectors-3/#subject; type: dfn; text: subject;
26 </pre>
27 <style>
28 table.source-demo-pair {
29 width: 100%;
30 }
32 .in-cards-demo {
33 width: 13em;
34 height: 8em;
36 padding: 4px;
37 border: medium solid blue;
38 margin: 6px;
40 font: medium/1.3 Times New Roman, Times, serif;
41 white-space: nowrap;
42 }
44 .bouncy-columns-demo {
45 width: 6em;
46 height: 10em;
47 float: left;
48 margin: 1em;
49 font: medium/1.25 Times New Roman, Times, serif;
50 white-space: nowrap;
51 }
52 .bouncy-columns-demo.one {
53 background: aqua; color: black;
54 transform: rotate(-3deg);
55 }
56 .bouncy-columns-demo.two {
57 background: yellow; color: black;
58 transform: rotate(3deg);
59 }
61 .article-font-inherit-demo {
62 font: 1em/1.25 Times New Roman, Times, serif;
63 white-space: nowrap;
64 }
65 .article-font-inherit-demo.one {
66 width: 12em;
67 font-size: 1.5em;
68 margin-bottom: 1em;
69 height: 4em;
70 }
71 .article-font-inherit-demo.two {
72 width: 11em;
73 margin-left: 5em;
74 margin-right: 2em;
75 }
77 .dark-columns-demo {
78 width: 6em;
79 height: 10em;
80 float: left;
81 margin-right: 1em;
82 font: medium/1.25 Times New Roman, Times, serif;
83 white-space: nowrap;
84 }
85 .dark-columns-demo.one {
86 background: aqua; color: black;
87 }
88 .dark-columns-demo.one :link {
89 color: blue;
90 }
91 .dark-columns-demo.one :visited {
92 color: purple;
93 }
94 .dark-columns-demo.two {
95 background: navy; color: white;
96 }
97 .dark-columns-demo.two :link {
98 color: aqua;
99 }
100 .dark-columns-demo.two :visited {
101 color: fuchsia;
102 }
104 .article-max-lines-demo {
105 font: 1em/1.25 Times New Roman, Times, serif;
106 white-space: nowrap;
107 }
108 .article-max-lines-demo.one::first-letter {
109 font-size: 2em;
110 line-height: 0.9;
111 }
112 .article-max-lines-demo.one {
113 font-size: 1.5em;
114 width: 16em;
115 }
116 .article-max-lines-demo.two {
117 width: 11.5em;
118 float: left; margin-right: 1em;
119 }
120 .article-max-lines-demo.three {
121 width: 11.5em;
122 float: left;
123 }
124 </style>
126 <p>
127 </p>
129 <h2 id="intro">
130 Introduction</h2>
132 <p>
133 In CSS Level 1 [[CSS1]], placing more content than would fit
134 inside an element with a specified size
135 was generally an authoring error.
136 Doing so caused the content to extend
137 outside the bounds of the element,
138 which would likely cause
139 that content to overlap with other elements.
140 </p>
142 <p>
143 CSS Level 2 [[CSS21]] introduced the 'overflow' property,
144 which allows authors to have overflow be handled by scrolling,
145 which means it is no longer an authoring error.
146 It also allows authors to specify
147 that overflow is handled by clipping,
148 which makes sense when the author's intent
149 is that the content not be shown.
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 <p>
189 CSS uses the term <dfn>overflow</dfn> to describe
190 the contents of a box
191 that extend outside that one of that box's edges
192 (i.e., its <i>content edge</i>, <i>padding edge</i>,
193 <i>border edge</i>, or <i>margin edge</i>).
194 The overflow might be described as the elements or features
195 that cause this overflow,
196 the non-rectangular region occupied by these features,
197 or, more commonly,
198 as the minimal rectangle that bounds that region.
199 A box's overflow is computed based on the boxes and styles
200 of the box and of all its descendants whose containing block chain
201 <span class="issue">undefined term?</span>
202 includes the box.
203 </p>
205 <p>
206 In most cases, any of these types of overflow
207 can be computed for any box
208 from the bounds and properties of that box,
209 and from the overflow (of that type)
210 of each of its children.
211 However, this is not always the case; for example,
212 when ''transform-style: preserve-3d'' [[CSS3-TRANSFORMS]] is used on
213 some of the children, their descendants with
214 ''transform-style: preserve-3d'' must also be examined.
215 </p>
217 <h3 id="ink-overflow">Ink overflow</h3>
219 <p>
220 The <dfn id="ink-overflow0">ink overflow</dfn> of a box
221 is the part of that box and its contents that
222 creates a visual effect outside of
223 the box's border box.
224 </p>
226 <p>
227 Since some effects in CSS (for example, the blurs in
228 'text-shadow' [[CSS3TEXT]] and 'box-shadow' [[CSS3BG]])
229 do not define what visual extent they cover, the extent
230 of the <a>ink overflow</a> is undefined.
231 </p>
233 <p class="issue">
234 Should we try to define it at all and just leave pieces undefined?
235 </p>
237 <p>
238 The <dfn>ink overflow region</dfn> is the non-rectangular region
239 occupied by the <a>ink overflow</a>, and the
240 <dfn>ink overflow rectangle</dfn> is
241 the minimal rectangle whose axis is aligned to the box's axes
242 and contains the <a>ink overflow region</a>.
243 Note that the <a>ink overflow rectangle</a> is a rectangle
244 in the box's coordinate system, but might be non-rectangular
245 in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
246 </p>
248 <h3 id="scrollable-overflow">Scrollable overflow</h3>
250 <p>
251 The <dfn id="scrollable-overflow0">scrollable overflow</dfn> of a box is the
252 set of things extending outside of that box's padding edge
253 for which a scrolling mechanism needs to be provided.
254 </p>
256 <p class="issue">
257 The following definition should be rewritten to use
258 the concept of <a href="http://dev.w3.org/csswg/css-transforms/#3d-rendering-context">3D rendering context</a> [[!CSS3-TRANSFORMS]]
259 and related terms,
260 particularly once those concepts stabilize following changes
261 proposed in the CSS WG meeting on the morning of 2014-01-28.
262 </p>
264 <p>
265 Given the following definitions
266 <span class="issue">which belong in [[CSS3-TRANSFORMS]]</span>:
267 </p>
269 <dl>
270 <dt><dfn>3d-preserving child</dfn></dt>
271 <dd>
272 A child box B of a containing block C is a 3d-preserving
273 child if it has ''transform-style: preserve-3d''
274 and the user-agent is not required to flatten it
275 based on the <a href="http://www.w3.org/TR/css3-transforms/#transform-style-property">requirements</a> in [[!CSS3-TRANSFORMS]].
276 </dt>
277 <dt><dfn>non-3d-preserving child</dfn></dt>
278 <dd>
279 A child C of a box P is a non-3d-preserving-child if
280 it is not a <a>3d-preserving child</a>.
281 </dd>
282 <dt><dfn>3d-preserving descendant</dfn></dt>
283 <dd>
284 Box D is a 3d-preserving descendant of box A if A is
285 an ancestor of D, and D and all of the boxes (if any)
286 in the containing block chain from D to A
287 are <a>3d-preserving child</a> boxes.
288 </dd>
289 </dl>
291 <p>The scrollable overflow of a box is the union of the following things,
292 all adjusted for transforms <span class="issue">undefined concept!</span> into the box's coordinate space:</p>
294 <ul>
295 <li>
296 for the box and all of its <a>3d-preserving descendant</a> boxes:
297 <ul>
298 <li>the box's own padding edge (for the box itself) or border edge (for <a>3d-preserving descendant</a> boxes)</li>
299 <li>the bounds <span class="issue">undefined term!</span> of any text directly in the box</li>
300 <li><span class="issue">MORE HERE!</span>
301 </ul>
302 <li>
303 for all the <a>non-3d-preserving child</a> boxes of the
304 box and its <a>3d-preserving descendant</a> boxes,
305 the scrollable overflow of the box
306 </li>
307 </ul>
309 <p class="issue">
310 I wrote this definition off the top of my head,
311 so it can't possibly be right.
312 It's missing tons of pieces!
313 </p>
315 <p class="issue">
316 The handling of preserve-3d subtrees here is probably wrong;
317 the elements should probably count
318 only towards the overflow of the element that flattens them.
319 </p>
321 <p>
322 The <dfn>scrollable overflow region</dfn> is the non-rectangular region
323 occupied by the <a>scrollable overflow</a>, and the
324 <dfn>scrollable overflow rectangle</dfn> is
325 the minimal rectangle whose axis is aligned to the box's axes
326 and contains the <a>scrollable overflow region</a>.
327 Note that the <a>scrollable overflow rectangle</a> is a rectangle
328 in the box's coordinate system, but might be non-rectangular
329 in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
330 </p>
332 <h3 id="border-box-overflow">Border box overflow</h3>
334 <p class="issue">
335 This concept has been proposed for some uses, such as for
336 determining what the 'outline' property goes around, and
337 as the basis of a coordinate system for specifying clips and masks,
338 but it's not clear if it's needed.
339 </p>
341 <p>
342 The <dfn>border-box overflow</dfn> of a box is the
343 union of the box's border edge and the border edges of
344 the box's descendants.</p>
345 </p>
347 <p class="issue">
348 If needed, define more formally, as for scrollable overflow above.
349 (Maybe even share the definitions in an appropriate way!)
350 </p>
352 <p>
353 The <dfn>border-box overflow region</dfn> is the non-rectangular region
354 occupied by the <a>border-box overflow</a>, and the
355 <dfn>border-box overflow rectangle</dfn> is
356 the minimal rectangle whose axis is aligned to the box's axes
357 and contains the <a>border-box overflow region</a>.
358 Note that the <a>border-box overflow rectangle</a> is a rectangle
359 in the box's coordinate system, but might be non-rectangular
360 in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
361 </p>
363 <h2 id="overflow-properties">Overflow properties</h2>
365 <p>
366 The 'overflow-x' property specifies
367 the handling of overflow in the horizontal direction
368 (i.e., overflow from the left and right sides of the box),
369 and the 'overflow-y' property specifies the handling
370 of overflow in the vertical direction
371 (i.e., overflow from the top and bottom sides of the box)
372 </p>
374 <table class=propdef>
375 <tr>
376 <th>Name:
377 <td><dfn>overflow-x</dfn>, <dfn>overflow-y</dfn>
378 <tr>
379 <th>Value:
380 <td>visible | hidden | scroll | auto | paged-x | paged-y | paged-x-controls | paged-y-controls | fragments
381 <tr>
382 <th>Initial:
383 <td>visible
384 <tr>
385 <th>Applies to:
386 <td>block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
387 <tr>
388 <th>Inherited:
389 <td>no
390 <tr>
391 <th>Percentages:
392 <td>N/A
393 <tr>
394 <th>Media:
395 <td>visual
396 <tr>
397 <th>Computed value:
398 <td>see below
399 <tr>
400 <th>Animatable:
401 <td>no
402 <tr>
403 <th>Canonical order:
404 <td><abbr title="follows order of property value definition">per grammar</abbr>
405 </table>
407 <p>
408 The 'overflow' property is a shorthand property
409 that sets the specified values of both 'overflow-x' and 'overflow-y'
410 to the value specified for 'overflow'.
411 </p>
413 <table class=propdef>
414 <tr>
415 <th>Name:
416 <td><dfn>overflow</dfn>
417 <tr>
418 <th>Value:
419 <td>visible | hidden | scroll | auto | paged-x | paged-y | paged-x-controls | paged-y-controls | fragments
420 <tr>
421 <th>Initial:
422 <td>see individual properties
423 <tr>
424 <th>Applies to:
425 <td>block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
426 <tr>
427 <th>Inherited:
428 <td>no
429 <tr>
430 <th>Percentages:
431 <td>N/A
432 <tr>
433 <th>Media:
434 <td>visual
435 <tr>
436 <th>Computed value:
437 <td>see individual properties
438 <tr>
439 <th>Animatable:
440 <td>no
441 <tr>
442 <th>Canonical order:
443 <td><abbr title="follows order of property value definition">per grammar</abbr>
444 </table>
446 <p>The values of these properties are:</p>
448 <dl dfn-for="overflow" dfn-type="value">
449 <dt><dfn>visible</dfn>
450 <dd>
451 There is no special handling of overflow, that is, it
452 may be rendered outside the block container.
453 </dd>
454 <dt><dfn>hidden</dfn>
455 <dt><dfn>scroll</dfn>
456 <dt><dfn>auto</dfn>
457 <dd>
458 These values are collectively the <dfn dfn>scrolling values</dfn>;
459 they are defined in the section on
460 <a href="#scrolling-overflow">scrolling and hidden overflow</a>.
461 </dd>
462 <dt><dfn>paged-x</dfn>
463 <dt><dfn>paged-y</dfn>
464 <dt><dfn>paged-x-controls</dfn>
465 <dt><dfn>paged-y-controls</dfn>
466 <dt><dfn>fragments</dfn>
467 <dd>
468 These values are collectively the <dfn dfn>fragmenting values</dfn>;
469 they are defined in the sections on
470 <a href="#paginated-overflow">paginated overflow</a> and
471 <a href="#fragment-overflow">fragment overflow</a>.
472 </dd>
473 </dl>
475 <div id="overflow-computed-values">
476 <p>The computed values of 'overflow-x' and 'overflow-y'
477 are determined from the cascaded values [[!CSS3CASCADE]]
478 based on the following rules:</p>
480 <ol>
481 <li>
482 If one or both of the cascaded values are
483 <a>fragmenting values</a>, then:
484 <ol>
485 <li>
486 If one of the cascaded values is one of the
487 <a>fragmenting values</a>
488 and the other is not,
489 then the computed values are
490 the same as the cascaded values.
491 </li>
492 <li>
493 If both of the cascaded values are <a>fragmenting values</a>, then:
494 <ol>
495 <li>
496 for horizontal writing mode [[!CSS3-WRITING-MODES]],
497 the computed value for 'overflow-y' is the cascaded value
498 and the computed value for 'overflow-x' is ''overflow/hidden'', or
499 </li>
500 <li>
501 for vertical writing mode [[!CSS3-WRITING-MODES]],
502 the computed value for 'overflow-x' is the cascaded value
503 and the computed value for 'overflow-y' is ''overflow/hidden''.
504 </li>
505 </ol>
506 </li>
507 </ol>
508 </li>
509 <li>
510 Otherwise, if one cascaded values is
511 one of the <a>scrolling values</a>
512 and the other is ''overflow/visible'',
513 then computed values are the cascaded values
514 with ''overflow/visible'' changed to ''overflow/auto''.
515 </li>
516 <li>
517 Otherwise, the computed values are as specified.
518 </li>
519 </ol>
520 </div>
522 <p class="issue">
523 Are all 4 of the ''paged-*'' values really needed?
524 </p>
526 <p>
527 When the <a>fragmenting values</a> are used,
528 the overflow from the fragments themselves
529 treats the fragmenting value as ''overflow/hidden''.
530 <span class="issue">Is this the right behavior?</span>
531 <span class="issue">Give example.</span>
532 </p>
534 <p class="issue">
535 [[CSS3-MARQUEE]] describes an 'overflow-style' property,
536 but it has not picked up implementation experience
537 that the working group is aware of.
538 Should this document treat 'overflow-style' as a defunct proposal,
539 or should this document describe the 'overflow-style' property
540 and attempt to revive it,
541 despite that implementations have implemented
542 'overflow-x' and 'overflow-y' instead?
543 </p>
545 <p class="issue">
546 There are <a href="http://lists.w3.org/Archives/Public/www-style/2012May/1197.html">discussions</a>
547 about how overflow, overflow-style, overflow-x and overflow-y
548 should work and interact with each other.
549 Until consensus on this topic is reached,
550 it is not completely clear which of these
551 should be used for
552 paged-x | paged-y | paged-x-controls | paged-y-controls | fragments
553 </p>
555 <h2 id="scrolling-overflow">Scrolling and hidden overflow</h2>
557 <p class="issue">
558 Move material from [[CSS21]] and [[CSS3BOX]] here.
559 </p>
561 <p class="issue">
562 Explain which directions allow scrolling and which don't,
563 as a function of 'direction'
564 (including propagation of 'direction' to the ICB).
565 </p>
567 <h2 id="paginated-overflow">Paginated overflow</h2>
569 <p class="issue">overflow:paginate or overflow:pages (or paged-x, paged-y, paged-x-controls, paged-y-controls as [[CSS3GCPM]] has?)</p>
571 <p class="issue">Ability to display N pages at once
572 rather than just one page at once?</p>
574 <p class="issue">
575 The current implementation of paginated overflow uses
576 the 'overflow'/'overflow-x'/'overflow-y' properties
577 rather than the 'overflow-style' property as proposed
578 in the [[CSS3GCPM]] draft
579 (which also matches the [[CSS3-MARQUEE]] proposal).
580 We should probably switch away from 'overflow-style',
581 but that's not 100% clear.
582 </p>
584 <h2 id="fragment-overflow">Fragment overflow</h2>
586 <p>
587 This section introduces and defines the meaning of
588 the new ''fragments'' value of the 'overflow' property.
589 </p>
591 <p>
592 When the computed value of 'overflow' for an element is ''fragments'',
593 and implementations would otherwise have created a box for the element,
594 then implementations must create a sequence of <dfn>fragment box</dfn>es
595 for that element.
596 (It is possible for an element with ''overflow: fragments''
597 to generate only one <a>fragment box</a>.
598 However, if an element's computed 'overflow' is not ''fragments'',
599 then its box is not a <a>fragment box</a>.)
600 Every <a>fragment box</a> is a fragmentation container,
601 and any overflow
602 that would cause that fragmentation container to fragment
603 causes another <a>fragment box</a> created as a next sibling
604 of the previous one.
605 <span class="issue">Or is it as though it's a next sibling of
606 the element? Need to figure out exactly how this interacts with
607 other box-level fixup.</span>
608 Additionally, if the <a>fragment box</a> is also
609 a multi-column box (as defined in [[!CSS3COL]]
610 <span class="issue">though it defines <i>multi-column element</i></span>)
611 any content that would lead to the creation of <a>overflow columns</a> [[!CSS3COL]]
612 instead is flown into an additional fragment box.
613 However, fragment boxes may themselves be broken
614 (due to fragmentation in a fragmentation context outside of them,
615 such as pages, columns, or other fragment boxes);
616 such breaking leads to fragments of the same fragment box
617 rather than multiple fragment boxes.
618 (This matters because fragment boxes may be styled by their index;
619 such breaking leads to multiple fragments of a fragment box
620 with a single index.
621 This design choice is so that
622 breaking a fragment box across pages does not break
623 the association of indices to particular pieces of content.)
624 <span class="issue">Should a forced break that breaks to
625 an outer fragmentation context cause a new fragment of a single
626 fragment box or a new fragment box?</span>
627 <span class="issue">Should we find a term other than
628 <a>fragment box</a> here to make this a little less confusing?</span>
629 </p>
631 <p class="issue">
632 What if we want to be able to style the pieces of an element
633 split within another type of fragmentation context?
634 These rules prevent ever using ''::nth-fragment()'' for that,
635 despite that the name seems the most logical name for such a feature.
636 </p>
638 <div class="example">
639 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
640 <title>Breaking content into
641 equal-sized cards</title>
642 <style>
643 .in-cards {
644 overflow: fragments;
646 width: 13em;
647 height: 8em;
649 padding: 4px;
650 border: medium solid blue;
651 margin: 6px;
653 font: medium/1.3 Times New
654 Roman, Times, serif;
655 }
656 </style>
657 <div class="in-cards">
658 In this example, the text in the div
659 is broken into a series of cards.
660 These cards all have the same style.
661 The presence of enough content to
662 overflow one of the cards causes
663 another one to be created. The second
664 card is created just like it's the
665 next sibling of the first.
666 </div></pre></td><td>
667 <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>
668 <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>
669 </td></tr></table>
670 </div>
672 <p class="issue">
673 We should specify that ''overflow: fragments'' does not apply
674 to at least some table parts,
675 and perhaps other elements as well.
676 We need to determine exactly which ones.
677 </p>
679 <p class="issue">
680 This specification needs to say which type of
681 fragmentation context is created
682 so that it's clear which values of the 'break-*' properties
683 cause breaks within this context.
684 We probably want ''break-*: region'' to apply.
685 </p>
687 <p class="issue">
688 This specification needs a processing model
689 that will apply in cases where the layout containing the
690 fragments has characteristics that use the intrinsic size of the fragments
691 to change the amount of space available for them,
692 such as [[CSS3-GRID-LAYOUT]].
693 There has already been some work on such a processing model
694 in [[CSS3-REGIONS]],
695 and the work done on a model there,
696 and the editors of that specification,
697 should inform what happens in this specification.
698 </p>
700 <h3 id="fragment-styling">Fragment styling</h3>
702 <h4 id="fragment-pseudo-element">The ::nth-fragment() pseudo-element</h4>
704 <p>
705 The ::nth-fragment() pseudo-element is a pseudo-element
706 that describes some of the <a>fragment box</a>es generated by an element.
707 The argument to the pseudo-element takes the same syntax
708 as the argument to the :nth-child() pseudo-class
709 defined in [[!SELECT]], and has the same meaning
710 except that the number is relative to
711 <a>fragment box</a>es generated by the element
712 instead of siblings of the element.
713 </p>
715 <p class="note">
716 Selectors that allow addressing fragments
717 by counting from the end rather than the start
718 are intentionally not provided.
719 Such selectors would interfere with determining
720 the number of fragments.
721 </p>
723 <p class="issue">
724 Depending on future discussions,
725 this ''::nth-fragment(<var>an+b</var>)'' syntax
726 may be replaced with
727 the new ''::fragment:nth(<var>an+b</var>)'' syntax.
728 </p>
730 <h4 id="style-of-fragments">Styling of fragments</h4>
732 <p class="issue">
733 Should this apply to fragment overflow only,
734 or also to paginated overflow?
735 (If it applies,
736 then stricter property restrictions would be needed
737 for paginated overflow.)
738 </p>
740 <p>
741 In the absence of rules with ''::nth-fragment()'' pseudo-elements,
742 the computed style for each <a>fragment box</a>
743 is the computed style for the element
744 for which the <a>fragment box</a> was created.
745 However, the style for a <a>fragment box</a> is also influenced
746 by rules whose selector's <a>subject</a> [[!SELECT]]
747 has an ''::nth-fragment()'' pseudo-element,
748 if the 1-based number of the <a>fragment box</a> matches
749 that ''::nth-fragment()'' pseudo-element
750 and the selector (excluding the ''::nth-fragment()'' pseudo-element)
751 matches the element generating the fragments.
752 </p>
754 <p>
755 When determining the style of the <a>fragment box</a>,
756 these rules that match the fragment pseudo-element
757 cascade together with the rules that match the element,
758 with the fragment pseudo-element adding the specificity
759 of a pseudo-class to the specificity calculation.
760 <span class="issue">Does this need to be specified in
761 the cascading module as well?</span>
762 </p>
764 <div class="example">
765 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
766 <style>
767 .bouncy-columns {
768 overflow: fragments;
769 width: 6em;
770 height: 10em;
771 float: left;
772 margin: 1em;
773 font: medium/1.25 Times New
774 Roman, Times, serif;
775 }
776 .bouncy-columns::nth-fragment(1) {
777 background: aqua; color: black;
778 transform: rotate(-3deg);
779 }
780 .bouncy-columns::nth-fragment(2) {
781 background: yellow; color: black;
782 transform: rotate(3deg);
783 }
784 </style>
785 <div class="bouncy-columns">
786 <i>...</i>
787 </div></pre></td><td>
788 <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>
789 <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>
790 <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>
791 </td></tr></table>
792 </div>
794 <p>
795 Styling an ''::nth-fragment()'' pseudo-element with the 'overflow'
796 property does take effect;
797 if a <a>fragment box</a> has a
798 computed value of 'overflow' other than ''fragments''
799 then that fragment box is the last fragment.
800 However, overriding 'overflow' on the first fragment
801 does not cause the <a>fragment box</a> not to exist;
802 whether there are fragment boxes at all is determined by
803 the computed value of overflow for the element.
804 <span class="issue">Need to reword this to refer to the
805 appropriate choice of 'overflow-x' or 'overflow-y',
806 and then point to rule about the handling of the other one
807 of 'overflow-x' or 'overflow-y'.</span>
808 </p>
810 <p>
811 Styling an ''::nth-fragment()'' pseudo-element with the 'content'
812 property has no effect;
813 the computed value of 'content' for the fragment box
814 remains the same as the computed value of content for the element.
815 </p>
817 <p>
818 Specifying ''display: none'' for a <a>fragment box</a> causes
819 the fragment box with that index not to be generated.
820 However, in terms of the indices
821 used for matching ''::nth-fragment()'' pseudo-elements
822 of later fragment boxes,
823 it still counts as though it was generated.
824 However, since it is not generated, it does not contain any content.
825 </p>
827 <p>
828 Specifying other values of 'display', 'position',
829 or 'float' is permitted, but is not allowed to change
830 the computed value of 'display-inside'.
831 (Since 'overflow', 'overflow-x', and 'overflow-y' only
832 apply to block containers, flex containers, and grid containers
833 the computed value of 'display-inside' is always
834 ''display-inside/block'', ''display-inside/flex'', or
835 ''display-inside/grid''.
836 <span class="issue">Need to specify exactly how this works,
837 but it depends on
838 having 'display-inside' and 'display-outside' specified.</span>
839 </p>
841 <p>
842 To match the model for other pseudo-elements
843 where the pseudo-elements live inside their corresponding element,
844 declarations in ''::nth-fragment()'' pseudo-elements override
845 declarations in rules without the pseudo-element.
846 The relative priority within such declarations is determined
847 by normal cascading order (see [[!CSS21]]).
848 </p>
850 <p>
851 Styles specified on ''::nth-fragment()'' pseudo-elements
852 do affect inheritance to content within the <a>fragment box</a>.
853 In other words, the content within the <a>fragment box</a> must
854 inherit from the fragment box's style (i.e., the pseudo-element style)
855 rather than directly from the element.
856 This means that elements split between fragment boxes may
857 have different styles for different parts of the element.
858 </p>
860 <p class="issue">
861 This inheritance rule allows specifying styles indirectly
862 (by using explicit ''inherit'' or using default inheritance
863 on properties that don't apply to ''::first-letter'')
864 that can't be specified directly
865 (based on the rules in the next section).
866 This is a problem.
867 The restrictions that apply to styling inside fragments
868 should also apply to inheritance from fragments.
869 </p>
871 <div class="example">
872 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
873 <style>
874 .article {
875 overflow: fragments;
876 }
877 .article::nth-fragment(1) {
878 font-size: 1.5em;
879 margin-bottom: 1em;
880 height: 4em;
881 }
882 .article::nth-fragment(2) {
883 margin-left: 5em;
884 margin-right: 2em;
885 }
886 </style>
887 <div class="article">
888 The <code>font-size</code> property<i>...</i>
889 </div></pre></td><td>
890 <div class="article-font-inherit-demo one">The <code>font-size</code> property<br>specified on the fragment<br>is inherited into the</div>
891 <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>
892 </td></tr></table>
893 </div>
895 <h4 id="style-in-fragments">Styling inside fragments</h4>
897 <p class="issue">
898 Should this apply to fragment overflow only,
899 or also to paginated overflow,
900 or even to pagination across pages?
901 </p>
903 <p>
904 The ''::nth-fragment()'' pseudo-element
905 can also be used to style
906 content inside of a <a>fragment box</a>.
907 Unlike the ''::first-line'' and ''::first-letter'' pseudo-elements,
908 the ''::nth-fragment()'' pseudo-element can be applied
909 to parts of the selector other than the subject:
910 in particular, it can match ancestors of the subject.
911 However, the only CSS properties applied
912 by rules with such selectors
913 are those that apply
914 to the ''::first-letter'' pseudo-element.
915 </p>
917 <p>
918 To be more precise,
919 when a rule's selector has ''::nth-fragment()'' pseudo-elements
920 attached to parts of the selector other than the subject,
921 the declarations in that rule apply to
922 a fragment (or pseudo-element thereof) when:
923 </p>
924 <ol>
925 <li>
926 the declarations are for properties that apply to the
927 ''::first-letter'' pseudo-element,
928 </li>
929 <li>
930 the declarations would apply to
931 that fragment (or pseudo-element thereof)
932 had those ''::nth-fragment()'' pseudo-elements been removed,
933 with a particular association between
934 each sequence of simple selectors and the element it matched,
935 and
936 </li>
937 <li>
938 for each removed ''::nth-fragment()'' pseudo-element,
939 the fragment lives within a <a>fragment box</a>
940 of the element associated in that association
941 with the selector that the pseudo-element was attached to,
942 and whose index matches the pseudo-element.
943 </li>
944 </ol>
946 <div class="example">
947 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
948 <style>
949 .dark-columns {
950 overflow: fragments;
951 width: 6em;
952 height: 10em;
953 float: left;
954 margin-right: 1em;
955 font: medium/1.25 Times New
956 Roman, Times, serif;
957 }
958 .dark-columns::nth-fragment(1) {
959 background: aqua; color: black;
960 }
961 .dark-columns::nth-fragment(1) :link {
962 color: blue;
963 }
964 .dark-columns::nth-fragment(1) :visited {
965 color: purple;
966 }
967 .dark-columns::nth-fragment(2) {
968 background: navy; color: white;
969 }
970 .dark-columns::nth-fragment(2) :link {
971 color: aqua;
972 }
973 .dark-columns::nth-fragment(2) :visited {
974 color: fuchsia;
975 }
976 </style>
977 <div class="dark-columns">
978 <i>...</i>
979 </div></pre></td><td>
980 <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>
981 <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>
982 </td></tr></table>
983 </div>
986 <h3 id="max-lines">The 'max-lines' property</h3>
988 <p>
989 Authors may wish to style the opening lines of an element
990 with different styles
991 by putting those opening lines in a separate fragment.
992 However, since it may be difficult to predict the exact height
993 occupied by those lines
994 in order to restrict the first fragment to that height,
995 this specification introduces a 'max-lines' property
996 that forces a fragment to break
997 after a specified number of lines.
998 This forces a break after the given number of lines
999 contained within the element or its descendants,
1000 as long as those lines are in the same block formatting context.
1001 </p>
1003 <table class=propdef>
1004 <tr>
1005 <th>Name:
1006 <td><dfn>max-lines</dfn>
1007 <tr>
1008 <th>Value:
1009 <td>none | <integer>
1010 <tr>
1011 <th>Initial:
1012 <td>none
1013 <tr>
1014 <th>Applies to:
1015 <td>fragment boxes
1016 <tr>
1017 <th>Inherited:
1018 <td>no
1019 <tr>
1020 <th>Animatable:
1021 <td>as <a href="http://www.w3.org/TR/css3-transitions/#animatable-types">integer</a>
1022 <tr>
1023 <th>Percentages:
1024 <td>N/A
1025 <tr>
1026 <th>Media:
1027 <td>visual
1028 <tr>
1029 <th>Computed value:
1030 <td>specified value
1031 <tr>
1032 <th>Canonical order:
1033 <td><abbr title="follows order of property value definition">per grammar</abbr>
1034 </table>
1036 <dl dfn-for="max-lines" dfn-type="value">
1037 <dt><dfn>none</dfn>
1038 <dd>
1039 <p>
1040 Breaks occur only as specified elsewhere.
1041 </p>
1042 </dd>
1044 <dt><dfn><integer></dfn>
1045 <dd>
1046 <p>
1047 In addition to any breaks specified elsewhere,
1048 a break is forced before any line that would exceed
1049 the given number of lines
1050 being placed inside the element
1051 (excluding lines that are in
1052 a different block formatting context from
1053 the block formatting context to which
1054 an unstyled child of the element would belong).
1055 </p>
1057 <p class="issue">
1058 If there are multiple boundaries between this line
1059 and the previous, where exactly (in terms of element
1060 boundaries) is the break forced?
1061 </p>
1063 <p>
1064 Only positive integers are accepted.
1065 Zero or negative integers are a parse error.
1066 </p>
1067 </dd>
1068 </dl>
1070 <p class="issue">Should this apply to fragment overflow only, or also
1071 to pagination?</p>
1073 <div class="example">
1074 <table class="source-demo-pair"><tr><td><pre><!DOCTYPE HTML>
1075 <style>
1076 .article {
1077 overflow: fragments;
1078 }
1079 .article::first-letter {
1080 font-size: 2em;
1081 line-height: 0.9;
1082 }
1083 .article::nth-fragment(1) {
1084 font-size: 1.5em;
1085 max-lines: 3;
1086 }
1087 .article::nth-fragment(2) {
1088 column-count: 2;
1089 }
1090 </style>
1091 <div class="article">
1092 <i>...</i>
1093 </div></pre></td><td>
1094 <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>
1095 <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>
1096 <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>
1097 </td></tr></table>
1098 </div>
1100 <h2 id="static-media">Overflow in static media</h2>
1102 <p class="issue">
1103 This specification should define useful behavior
1104 for all values of 'overflow'
1105 in static media (such as print).
1106 Current implementation behavior is quite poor and
1107 produces unexpected results when authors have not considered
1108 what will happen when
1109 the content they produce for interactive media
1110 is printed.
1111 </p>
1113 <h2 class=no-num id="acknowledgments">
1114 Acknowledgments</h2>
1116 <p>
1117 Thanks especially to the feedback from
1118 Rossen Atanassov,
1119 Bert Bos,
1120 Tantek Ãelik,
1121 John Daggett,
1122 fantasai,
1123 Daniel Glazman,
1124 Vincent Hardy,
1125 Håkon Wium Lie,
1126 Peter Linss,
1127 Robert O'Callahan,
1128 Florian Rivoal,
1129 Alan Stearns,
1130 Steve Zilles,
1131 and all the rest of the
1132 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.
1133 </p>