forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverview.bs
1264 lines (1058 loc) · 51 KB
/
Overview.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class='metadata'>
Title: CSS Fragmentation Module Level 4
Status: ED
Work Status: Exploring
ED: https://drafts.csswg.org/css-break-4/
Shortname: css-break
Group: csswg
Level: 4
TR: https://www.w3.org/TR/css-break-4/
Editor: Rossen Atanassov, Microsoft, [email protected], w3cid 49885
Editor: Elika J. Etemad / fantasai, Invited Expert, http://fantasai.inkedblade.net/contact, w3cid 35400
Abstract: This module describes the fragmentation model that partitions a flow into pages, columns, or regions.
Abstract: It builds on the Page model module and introduces and defines the fragmentation model.
Abstract: It adds functionality for pagination, breaking variable fragment size and orientation, widows and orphans.
Ignored Terms: background positioning area, region chain, … message topic …, reference box
At Risk: the ''break-before/all'' value of 'break-before'/'break-after'
</pre>
<h1>CSS Fragmentation Module Level 4 <br> <small>Breaking the Web, one fragment at a time</small></h1>
<h2 id="intro">
Introduction</h2>
<div class=non-normative>
<em>This section is not normative.</em>
In [=paged media=]
(e.g., paper, transparencies, photo album pages,
pages displayed on computer screens as printed output simulations),
as opposed to [=continuous media=],
the content of the document is split into
one or more discrete display surfaces.
In order to avoid awkward breaks
(such as halfway through a line of text),
the layout engine must be able to shift around content
that would fall across the page break.
This process is called <dfn export>pagination</dfn>.
In CSS, in addition to [=paged media=],
certain layout features such as
<a href="https://www.w3.org/TR/css3-regions/">regions</a> [[CSS3-REGIONS]]
and <a href="https://www.w3.org/TR/css-multicol-1/">multi-column layout</a> [[CSS-MULTICOL-1]]
create a similarly fragmented environment.
The generic term for breaking content across containers is <a>fragmentation</a>.
This module explains how content breaks across
<a>fragmentation containers</a> (<a>fragmentainers</a>)
such as pages and columns
and how such breaks can be
<a href="https://www.w3.org/TR/css-break-3/#breaking-controls">controlled by the author</a>.
This specification is identical to
<a href="https://www.w3.org/TR/css-break-3/">CSS Fragmentation Level 3</a>
except for the addition of the 'margin-break' property
and the ''break-before/always'' and ''break-before/all'' values
of the 'break-before' and 'break-after' properties.
</div>
<h3 id="placement">
Module Interactions</h3>
This module replaces and extends the pagination controls defined in
[[CSS2]] <a href="https://www.w3.org/TR/CSS2/page.html#page-breaks">section 13.3</a>
and in [[CSS-PAGE-3]].
<!-- End section "Modules Interactions" -->
<h3 id="values">
Value Definitions</h3>
This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the <a>CSS-wide keywords</a> as their property value.
For readability they have not been repeated explicitly.
<h2 id="fragmentation-model">
Fragmentation Model and Terminology</h2>
<dl export>
<dt><dfn>fragmentation container</dfn> (<dfn>fragmentainer</dfn>)</dt>
<dd>
A box--
such as a page box, column box, or region--
that contains a portion (or all) of a <a>fragmented flow</a>.
Fragmentainers can be pre-defined, or generated as needed.
When breakable content would overflow a fragmentainer in the block dimension,
it breaks into the next container in its <a>fragmentation context</a>
instead.
<dt><dfn>fragmentation context</dfn></dt>
<dd>
An ordered series of <a>fragmentainers</a>,
such as created by a <a href="https://www.w3.org/TR/css-multicol-1/">multi-column container</a>,
a chain of <a href="https://www.w3.org/TR/css3-regions">CSS regions</a>,
or a [=paged media=] display.
A given fragmentation context can only have one block flow direction
across all its <a>fragmentainers</a>.
(Descendants of the <a>fragmentation root</a> may have other block flow directions,
but fragmentation proceeds according to the block flow direction applied to the <a>fragmentation root</a>.)
<dt><dfn>fragmented flow</dfn></dt>
<dd>
Content that is being laid out in a <a>fragmentation context</a>.
The <a>fragmented flow</a> consists of the content of a (possibly anonymous) box
called the <dfn>fragmentation root</dfn>.
<dt><dfn>fragmentation direction</dfn></dt>
<dd>
The block flow direction of the <a>fragmentation context</a>,
i.e. the direction in which content is fragmented.
(In this level of CSS, content only fragments in one dimension.)
<dt><dfn>fragmentation</dfn></dt>
<dd>
The process of splitting a content flow across the <a>fragmentainers</a>
that form a <a>fragmentation context</a>.
<dt><dfn>box fragment</dfn> or <dfn>fragment</dfn></dt>
<dd>
The portion of a box that belongs to exactly one <a>fragmentainer</a>.
A box in continuous flow always consists of only one fragment.
A box in a fragmented flow consists of one or more fragments.
Each fragment has its own share of the box’s border, padding, and margin,
and therefore has its own <a>padding area</a>, <a>border area</a>, and <a>margin area</a>.
(See 'box-decoration-break', which controls how these are affected by fragmentation.)
<dt><dfn>remaining fragmentainer extent</dfn></dt>
<dd>
The remaining <a>block-axis</a> space in the <a>fragmentainer</a> available to a given element,
i.e. between the end of preceding content in <a>fragmentainer</a>
and the edge of the <a>fragmentainer</a>.
</dl>
Each <dfn export>fragmentation break</dfn> (hereafter, <dfn>break</dfn>)
ends layout of the fragmented box in the current <a>fragmentainer</a>
and causes the remaining content to be laid out in the next <a>fragmentainer</a>,
in some cases causing a new <a>fragmentainer</a> to be generated
to hold the deferred content.
Note: Breaking inline content into lines is another form of fragmentation,
and similarly creates box fragments when it breaks
<a href="https://www.w3.org/TR/CSS2/visuren.html#inline-boxes">inline boxes</a>
across <a href="https://www.w3.org/TR/CSS2/visuren.html#line-box">line boxes</a>.
However, inline breaking is not covered here; see [[!CSS2]]/[[CSS-TEXT-3]].
Note:A box can be broken into multiple <a>fragments</a>
also due to bidi reordering of text
(see [[css-writing-modes-3#bidi-algo|Applying the Bidirectional Reordering Algorithm]]
in [[css-writing-modes-3#text-direction|CSS Writing Modes]])
or higher-level <a>display type</a> box splitting,
e.g. <a href="https://www.w3.org/TR/CSS2/visuren.html#img-anon-block">block-in-inline splitting</a>
(see <a href="https://www.w3.org/TR/CSS2/visuren.html#box-gen">CSS2§9.2</a>)
or <a href="https://www.w3.org/TR/css-multicol-1/#spanning-columns">column-spanner-in-block</a> splitting
(see <a href="https://www.w3.org/TR/css-multicol-1/#spanning-columns">CSS Multi-column Layout</a>).
The division into <a>box fragments</a> in these cases
does not depend on layout (sizing/positioning of content).
<h3 id="parallel-flows">
Parallel Fragmentation Flows</h3>
When multiple <a>formatting contexts</a> are laid out parallel to each other,
fragmentation is performed independently in each <a>formatting context</a>.
For example, if an element is floated,
then a forced break inside the float
will not affect the content outside the float
(except insofar as it may increase the height of the float).
UAs <em>may</em> (but are not required to)
adjust the placement of <a>unforced breaks</a> in parallel <a>formatting contexts</a>
to visually balance such side-by-side content,
but <em>must not</em> do so to match a <a>forced break</a>.
The following are examples of parallel flows
whose contents will fragment independently:
<ul>
<li>The contents of a float vs. the content wrapping outside the float.
<li>The contents of a float vs. the contents of an adjacent float.
<li>The contents of each table cell in a single table row.
<li>The contents of each grid item in a single grid row.
<li>The contents of each flex item in a flex layout row.
<li>The contents of absolutely-positioned elements
that cover the same range of their containing block's fragmentation context.
</ul>
Content overflowing the content edge of a fixed-size box
is considered parallel to the content after the fixed-size box
and follows the normal fragmentation rules.
Although overflowing content doesn't affect the size of the <a>fragmentation root</a> box,
it does increase the length of the <a>fragmented flow</a>,
spilling into or generating additional <a>fragmentainers</a> as necessary.
<h3 id="nested-flows">
Nested Fragmentation Flows</h3>
Breaking a <a>fragmentainer</a> <var>F</var> effectively splits the <a>fragmentainer</a>
into two <a>fragmentainers</a> (<var>F<sub>1</sub></var> and <var>F<sub>2</sub></var>).
The only difference is that,
with regards to the content of <a>fragmentainer</a> <var>F</var>,
the type of break
between the two pieces <var>F<sub>1</sub></var> and <var>F<sub>2</sub></var>
is the <a href="#break-types">type of break</a> created
by the <a>fragmentation context</a> that split <var>F</var>,
not the type of break normally created by <var>F</var>’s own <a>fragmentation context</a>.
<div class="example">
For example, if a region box is broken at a page boundary,
then the content of the region will be affected by a page break at that point
(but not by a region break).
</div>
<div class="note">
Note that when a multi-column container breaks across pages,
it generates a new row of columns on the next page for the rest of its content,
so that a page break within a multi-column container
is always both a page break and a column break.
</div>
<h2 id="breaking-controls">
Controlling Breaks</h2>
The following sections explain how breaks are controlled in a <a>fragmented flow</a>.
A page/column/region break opportunity between two boxes
is under the influence of
the containing block's 'break-inside' property,
the 'break-after' property of the preceding element,
and the 'break-before' property of the following element.
A page/column/region break opportunity between line boxes
is under the influence of
the containing block's 'break-inside', 'widows', and 'orphans' properties.
A fragmentation break can be
allowed, forced, or discouraged depending on the values of these properties.
A forced break overrides any break restrictions acting at that break point.
In the case of forced page breaks, the author can also specify
on which page (<a href="https://www.w3.org/TR/css-page-3/#left-right-first">left or right</a>)
the subsequent content should resume.
See the section on <a href="#breaking-rules">rules for breaking</a>
for the exact rules on how these properties affect fragmentation.
<h3 id="break-between">
Breaks Between Boxes: the 'break-before' and 'break-after' properties</h3>
<pre class="propdef">
Name: break-before, break-after
Value: auto | avoid | always | all | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region
Initial: auto
Applies to: block-level boxes, grid items, flex items, table row groups, table rows (but see prose)
Inherited: no
Computed value: specified keyword
Animation type: discrete
</pre>
These properties specify page/column/region break behavior
before/after the generated box.
The <dfn>forced break values</dfn>
''always'', ''all'', ''left'', ''right'', ''recto'', ''verso'', ''page'', ''column'' and ''region''
create a <a href="#forced-breaks">forced break</a> in the flow
while the <dfn>avoid break values</dfn>
''break-before/avoid'', ''break-before/avoid-page'', ''break-before/avoid-column'' and ''break-before/avoid-region''
indicate that content should be kept together.
Values for 'break-before' and 'break-after' are defined in the sub-sections below.
User Agents must apply these properties to boxes in the normal flow of the <a>fragmentation root</a>.
User agents should also apply these properties to floated boxes
whose containing block is in the normal flow of the root fragmented element.
User agents may also apply these properties to other boxes.
User agents must not apply these properties to absolutely-positioned boxes.
<h4 id="generic-break-values" class="no-num">
Generic Break Values</h4>
These values have an effect regardless of
the type of fragmented context containing the flow.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>auto</dfn>
<dd>
Neither force nor forbid a break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
<dt><dfn>avoid</dfn>
<dd>
Avoid a break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
<dt><dfn>always</dfn>
<dd>
Always force a break before/after the <a>principal box</a>.
The type of this break is that of the immediately-containing <a>fragmentation context</a>.
For example, in a <a>multi-column container</a> forces a <a>column break</a>;
in <a>paged media</a> not inside a <a>multi-column container</a>,
forces a <a>page break</a>.
<dt><dfn>all</dfn>
<dd>
Always force a break before/after the <a>principal box</a>.
This value breaks through all containing <a>fragmentation contexts</a>.
For example, inside a <a>multi-column container</a> in a <a>region</a> in a <a>multi-column container</a> in <a>paged media</a>,
it forces simultaneously a <a>column break</a> in the inner <a>multi-column container</a>,
a <a>region break</a>, a <a>column break</a> in the outer <a>multi-column container</a>,
and a <a>page break</a>.
Issue: It's unclear if this value is needed.
</dl>
<h4 id="page-break-values" class="no-num">
Page Break Values</h4>
These values only have an effect in paginated contexts;
if the flow is not paginated, they have no effect.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>avoid-page</dfn>
<dd>
Avoid a page break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
<dt><dfn>page</dfn>
<dd>
Always force a page break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
<dt><dfn>left</dfn>
<dd>
Force one or two page breaks before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a> so that the next page is formatted as a left page.
<dt><dfn>right</dfn>
<dd>
Force one or two page breaks before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a> so that the next page is formatted as a right page.
<dt><dfn>recto</dfn>
<dd>
Force one or two page breaks before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a> so that
the next page is formatted as either a left page or a right page,
whichever is second (according to the <a>page progression</a>) in a page spread.
<dt><dfn>verso</dfn>
<dd>
Force one or two page breaks before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a> so that
the next page is formatted as either a left page or a right page,
whichever is first (according to the <a>page progression</a>) in a page spread.
</dl>
<h4 id="column-break-values" class="no-num">
Column Break Values</h4>
These values only have an effect in multi-column contexts;
if the flow is not within a multi-column context, they have no effect.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>avoid-column</dfn>
<dd>
Avoid a column break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
<dt><dfn>column</dfn>
<dd>
Always force a column break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
</dl>
<h4 id="region-break-values" class="no-num">
Region Break Values</h4>
These values only have an effect in multi-region contexts;
if the flow is not linked across multiple regions, these values have no effect.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>avoid-region</dfn>
<dd>
Avoid a region break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
<dt><dfn>region</dfn>
<dd>
Always force a region break before/after the <a href="https://www.w3.org/TR/CSS2/visuren.html#block-boxes">principal box</a>.
</dl>
<h4 id="break-propagation">
Child→Parent Break Propagation</h4>
Since breaks are only allowed between siblings,
not between a box and its container
(see <a href="#possible-breaks">Possible Break Points</a>),
break values applied to children at the start/end of a parent
are <dfn lt="propagate|propagation">propagated</dfn> to the parent,
where they can take effect.
Specifically--
except in layout modes which define more specific rules
to account for reordering and parallel layout
(e.g. in <a href="http://www.w3.org/TR/css-flexbox-1/#pagination">flex layout</a> [[CSS-FLEXBOX-1]]
or <a href="http://www.w3.org/TR/css-grid-1/#pagination">grid layout</a> [[CSS-GRID-1]])--
a 'break-before' value on a first <a>in-flow</a> child box
is <a>propagated</a> to its container.
Likewise a 'break-after' value on a last <a>in-flow</a> child box
is <a>propagated</a> to its container.
(Conflicting values <a href="#forced-breaks">combine</a> as defined below.)
This propagation stops before it breaks through the nearest matching fragmentation context.
Break <a>propagation</a> does not affect <a>computed values</a>;
it is part of interpreting the elements’ computed values for layout.
<h3 id="break-within">
Breaks Within Boxes: the 'break-inside' property</h3>
<pre class="propdef">
Name: break-inside
Value: auto | avoid | avoid-page | avoid-column | avoid-region
Initial: auto
Applies to: all elements except inline-level boxes, internal ruby boxes, table column boxes, table column group boxes, absolutely-positioned boxes
Inherited: no
Computed value: specified keyword
Animation type: discrete
</pre>
This property specifies page/column/region break behavior
within the element's principal box.
Values have the following meanings:
<dl dfn-type=value dfn-for='break-inside,page-break-inside'>
<dt><dfn>auto</dfn>
<dd>
Impose no additional breaking constraints within the box.
<dt><dfn>avoid</dfn>
<dd>
Avoid breaks within the box.
<dt><dfn>avoid-page</dfn>
<dd>
Avoid a page break within the box.
<dt><dfn>avoid-column</dfn>
<dd>
Avoid a column break within the box.
<dt><dfn>avoid-region</dfn>
<dd>
Avoid a region break within the box.
</dl>
<h3 id="widows-orphans">
Breaks Between Lines: 'orphans', 'widows'</h3>
<pre class="propdef">
Name: orphans, widows
Value: <<integer>>
Initial: 2
Applies to: <a>block containers</a> that establish an <a>inline formatting context</a>
Inherited: yes
Computed value: specified integer
Animation type: by computed value type
</pre>
The 'orphans' property specifies the minimum number
of line boxes in a block container
that must be left in a <a>fragment</a> <em>before</em> a fragmentation break.
The 'widows' property specifies the minimum number
of line boxes of a block container
that must be left in a <a>fragment</a> <em>after</em> a break.
Examples of how they are used to control fragmentation breaks are given
<a href="#widows-orphans-example">below</a>.
Only positive integers are allowed as values of 'orphans' and 'widows'.
Negative values and zero are invalid and must cause the declaration to be
<a href="https://www.w3.org/TR/CSS2/conform.html#ignore">ignored</a>.
If a block contains fewer lines than the value of 'widows' or 'orphans',
the rule simply becomes that all lines in the block must be kept together.
<h3 id="page-break-properties">
Page Break Aliases: the 'page-break-before', 'page-break-after', and 'page-break-inside' properties</h3>
For compatibility with <a href="https://www.w3.org/TR/CSS2/page.html">CSS Level 2</a>,
UAs that conform to [[!CSS2]] must alias the
'page-break-before', 'page-break-after', and 'page-break-inside' properties
to 'break-before', 'break-after', and 'break-inside'
by treating the 'page-break-*' properties as [=legacy shorthands=] for the 'break-*' properties
with the following value mappings:
<table class="data">
<thead>
<tr><th>Shorthand ('page-break-*') Values
<th>Longhand ('break-*') Values
</thead>
<tbody>
<tr><td><css>auto | left | right | avoid</css>
<td><css>auto | left | right | avoid</css>
<tr><td><css>always</css>
<td><css>page</css>
</tbody>
</table>
<h2 id="breaking-rules">
Rules for Breaking</h2>
A <a>fragmented flow</a> may be broken across <a>fragmentainers</a> at a number of
<a href="#possible-breaks">possible break points</a>. In the case of
<a href="#forced-breaks">forced breaks</a>, the UA is required to
break the flow at that point. In the case of
<a href="#unforced-breaks">unforced breaks</a>, the UA has to choose
among the possible breaks that are allowed.
To guarantee progress, fragmentainers are assumed to have a minimum
<a>block size</a> of 1px regardless of their used size.
<h3 id="possible-breaks">
Possible Break Points</h3>
Fragmentation splits boxes in the block flow dimension.
In block-and-inline flow, breaks may occur at the following places:
<dl>
<dt id="btw-blocks">Class A</dt>
<dd>
Between sibling boxes of the following types:
<dl>
<dt>Block-parallel Fragmentation</dt>
<dd>
When the block flow direction of the siblings' containing block
is parallel to that of the fragmentation context:
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/visuren.html#positioning-scheme">in-flow</a> block-level boxes,
a float and an immediately-adjacent in-flow or floated box,
table row group boxes,
table row boxes,
multi-column column row boxes.
<dt>Block-perpendicular Fragmentation</dt>
<dd>
When the block flow direction of the siblings' containing block
is perpendicular to that of the fragmentation context:
table column group boxes,
table column boxes,
multi-column column boxes.
</dl>
<dt id="btw-lines">Class B</dt>
<dd>
Between line boxes inside a block container box.
<dt id="end-block">Class C</dt>
<dd>
Between the content edge of a block container box and the outer edges of its
child content (margin edges of block-level children or line box
edges for inline-level children) <em>if</em> there is a (non-zero)
gap between them.
<!-- XXX add example -->
</dl>
Note: There is no inherent prioritization among these classes of break points.
However, individual break points may be prioritized or de-prioritized
by using the <a href="#breaking-controls">breaking controls</a>.
Note: Other layout models may add breakpoints to the above classes.
For example, [[CSS-FLEXBOX-1]] adds certain points within a flex formatting context
to classes A and C.
Some content is not fragmentable, for example many types of
<a href="https://www.w3.org/TR/CSS2/conform.html#replaced-element">replaced elements</a> [[!CSS2]] (such as images or video),
scrollable elements, or a single line of text content.
Such content is considered <dfn>monolithic</dfn>:
it contains no possible break points.
Any forced breaks within such boxes
therefore cannot split the box,
and must therefore also be ignored by the box’s own fragmentation context.
In addition to any content which is not generally fragmentable,
UAs may consider as <a>monolithic</a> any elements with
'overflow' set to ''overflow/auto'' or ''overflow/scroll'' and
any elements with ''overflow: hidden'' and a non-''height/auto'' <a>logical height</a>
(and no specified maximum logical height).
Since line boxes contain no possible break points,
''inline-block'' and ''inline-table'' boxes
(and other inline-level <a>display types</a> that establish an <a>independent formatting context</a>)
may also be considered <a>monolithic</a>:
that is,
in the cases where a single line box is too large
to fit within its fragmentainer even by itself
and the UA chooses to split the line box,
it may fragment such boxes or it may treat them as monolithic.
<h3 id="break-types">
Types of Breaks</h3>
There are different types of breaks in CSS, defined based on the type of
fragmentainers they span:
<dl export>
<dt><dfn>page break</dfn></dt>
<dd>
A break between two <a href="https://www.w3.org/TR/css-page-3/#page-box">page boxes</a>.
[[!CSS-PAGE-3]]
<dt><dfn>spread break</dfn></dt>
<dd>
A break between two page boxes that are not associated with
<a href="https://www.w3.org/TR/css-page-3/#facing-pages">facing pages</a>.
A spread break is always also a page break.
[[!CSS-PAGE-3]]
<dt><dfn>column break</dfn></dt>
<dd>
A break between two <a href="https://www.w3.org/TR/css-multicol-1/#column-box">column boxes</a>.
Note that if the column boxes are on different pages, then the break is
also a <a>page break</a>.
Similarly, if the column boxes are in different regions,
then the break is also a <a>region break</a>.
[[!CSS-MULTICOL-1]]
<dt><dfn>region break</dfn></dt>
<dd>
A break between two <a href="https://www.w3.org/TR/css3-regions/#regions">regions</a>.
Note that if the region boxes are on different pages, then the break is
also a <a>page break</a>.
[[!CSS3-REGIONS]]
</dl>
Note: A fifth type of break is the [=line break=],
which is a break between two <a href="https://www.w3.org/TR/CSS2/visuren.html#line-box">line boxes</a>.
These are not covered in this specification; see [[!CSS2]] [[CSS-TEXT-3]].
<h3 id="forced-breaks">
Forced Breaks</h3>
A <dfn export>forced break</dfn> is one explicitly indicated by the style sheet author.
A <a>forced break</a> occurs at a <a href="#btw-blocks">class A break point</a> if,
among the 'break-after' properties specified on or <a>propagated</a> to the earlier sibling box
and the 'break-before' properties specified on or <a>propagated</a> to the later sibling box
there is at least one with a <a>forced break value</a>.
(Thus a <a>forced break value</a> effectively overrides any <a>avoid break value</a>
that also applies at that break point.)
When multiple <a>forced break values</a> apply to a single break point,
they combine such that all types of break are honored.
When ''left'', ''right'', ''recto'', and/or ''verso'' are combined,
the value specified on the latest element in the flow wins.
Note: A forced page break must also occur
at a <a href="#btw-blocks">class A break point</a>
if the last line box above this margin and the first one below it
do not have the same value for 'page'. See [[!CSS-PAGE-3]].
When a forced break occurs,
it forces ensuing content into the next fragmentainer
of the type associated with the break,
breaking through as many fragmentation contexts as necessary
until the specified break types are all satisfied.
If the forced break is not contained within a matching type of fragmentation context,
then the forced break has no effect.
<h3 id="unforced-breaks">
Unforced Breaks</h3>
While <a href="#breaking-controls">breaking controls</a> can force breaks,
they can also discourage them.
An <dfn export>unforced break</dfn> is one that is inserted automatically by the UA
in order to prevent content from overflowing the <a>fragmentainer</a>.
The following rules control whether unforced breaking
at a <a href="#possible-breaks">possible break point</a> is allowed:
<dl>
<dt>Rule 1</dt>
<dd>
A <a>fragmented flow</a> may break at a <a href="#btw-blocks">class A break point</a> only if
all the 'break-after' and 'break-before' values applicable to this
break point allow it, which is when at least one of them forces a
break or when none of them forbid it
(''break-before/avoid'' or ''break-before/avoid-page''/''break-before/avoid-column''/''break-before/avoid-region'', depending on the <a href="#break-types">break type</a>).
<dt>Rule 2</dt>
<dd>
However, if all of them are ''break-before/auto'' and a common ancestor of all
the elements has a 'break-inside' value of ''break-inside/avoid'', then breaking
here is not allowed.
<dt>Rule 3</dt>
<dd>
Breaking at a <a href="#btw-lines">class B break point</a> is allowed only if the number
of line boxes between the break and the start of the enclosing block
box is the value of 'orphans' or more, and the number of line boxes
between the break and the end of the box is the value of 'widows' or more.
<dt>Rule 4</dt>
<dd>
Additionally, breaking at <a href="#btw-blocks">class B</a> or
<a href="#end-block">class C</a> break points
is allowed only if the 'break-inside' property of all ancestors is ''break-inside/auto''.
</dl>
If the above doesn't provide enough break points to keep content from
overflowing the <a>fragmentainer</a>,
then rule 3 is dropped to provide more break points.
If that still does not lead to sufficient break points,
then rules 1, 2 and 4 are dropped in order to find additional breakpoints.
In this case the UA may use the <css>avoid</css>s that are in effect at those
points to weigh the appropriateness of the new breakpoints; however,
this specification does not suggest a precise algorithm.
If even that does not lead to sufficient break points,
<a href="#valdef-box-decoration-break-clone">cloned margins/border/padding</a>
at on the [=block-end=] side are truncated;
and if more room is still needed,
<a href="#valdef-box-decoration-break-clone">cloned margins/border/padding</a>
are truncated at the [=block-start=] side as well.
Finally, if there are no possible break points below the top of the fragmentainer,
and not all the content fits, the UA may break anywhere
in order to avoid losing content off the edge of the fragmentainer.
<span id="monolithic-breaking">
In such cases, the UA may also fragment the contents of <a>monolithic</a> elements
by slicing the element's graphical representation.
However, the UA must not break at the top of the page,
i.e. it must place at least some content on each fragmentainer,
so that each fragmentainer has a non-zero amount of content,
in order to guarantee progress through the content.
<h3 id="best-breaks">
Optimizing Unforced Breaks</h3>
While CSS requires that a <a>fragmented flow</a>
must break at allowed break points in order to avoid
overflowing the fragmentainers in its fragmentation context,
it does not define whether content breaks
at a particular <a href="#unforced-breaks">allowed break</a>.
However, it is recommended that user agents observe
the following guidelines
(while recognizing that they are sometimes contradictory):
<ul>
<li>Break as few times as possible.
<li>Make all fragmentainers that don't end with a forced break
appear to be equally filled with content.
<li>Avoid breaking inside a replaced element.
</ul>
<div class="example" id="widows-orphans-example">
Suppose, for example, that the style sheet contains ''orphans : 4'',
''widows : 2'', and there is space for 20 lines (line boxes) available
at the bottom of the current page, and the next block in normal flow
is considered for placement:
<ul>
<li>
If the block contains 20 line boxes or fewer, it should be placed
on the current page.
<li>
If the block contains 21 or 22 line boxes, the second fragment of
the paragraph must not violate the 'widows' constraint, and so
the second fragment must contain at least two line boxes;
likewise the first fragment must contain at least four line boxes.
<li>
If the block contains 23 line boxes or more, the first fragment should
contain 20 lines and the second fragment the remaining lines. But if
any fragment of the block is placed on the current page, that fragment
must contain at least four line boxes and the second fragment at least
two line boxes.
</ul>
Now suppose that 'orphans' is ''10'', 'widows' is ''20'', and there
are 8 lines available at the bottom of the current page:
<ul>
<li>
If the block contains 8 lines or fewer, it should be placed
on the current page.
<li>
If the block contains 9 lines or more, it must NOT be split
(that would violate the 'orphans' constraint), so it must
move as a block to the next page.
</ul>
</div>
Additionally, CSS imposes one requirement:
a zero-sized <a>box fragment</a>,
since it does not take up space,
must appear on the earlier side of a <a>fragmentation break</a>
if it is able to fit within the <a>fragmentainer</a>.
Note: A zero-sized <a>box fragment</a> will be pushed
to the next <a>fragmentainer</a>
if it is placed immediately after content
that itself overflows the <a>fragmentainer</a>.
<h2 id="breaking-boxes">
Box Model for Breaking</h2>
Note: The sizing terminology used in this section is defined in [[CSS-SIZING-3]].
<h3 id="varying-size-boxes">
Breaking into Varying-size Fragmentainers</h3>
When a flow is fragmented into varying-size fragmentainers,
the following rules are observed for adapting layout:
<ul>
<li>
Layout is performed per-fragmentainer,
with each fragmentainer continuing progress
from the breakpoint on the previous,
but recalculating sizes and positions
using its own size
as if the entire element were fragmented
across fragmentainers of this size.
Progress is measured in percentages (not absolute lengths)
of used/remaining fragmentainer size
and in amount of used/remaining content.
However, when laying out <a>monolithic</a> elements,
the UA may instead maintain a consistent <a>inline size</a>
and resolved <a>block size</a> across fragmentainers.
<li>
Intrinsic sizes are calculated and maintained
across the entire element.
Where an initial containing block size is needed
to resolve an intrinsic size,
assume the size of the first fragmentainer defining a fragmentation context.
<li>
Fragments of boxes that began on a previous fragmentainer
must obey placement rules with the additional constraint
that fragments must not be positioned above
the <a>block-start</a> edge of the fragmentainer.
If this results in a box's continuation fragment
shifting away from the <a>block-start</a> edge of the fragmentainer,
then ''box-decoration-break: clone'', if specified,
wraps the fragment with the box's margin
in addition to its padding and border.
<div class="figure">
<img src="images/Varying-Size-Fragmentainers.svg"
style="width: 75%"
alt="Illustration: Breaking in varying-size fragmentainers" >
<p class="caption">
Illustration of breaking in varying-size fragmentainers.
</div>
</ul>
Note: Since document order of elements doesn't change during fragmentation,
fragments are processed following the same rules that apply to continuous
media. In particular, the order of floats is preserved across all
fragments and follows the same rules as defined in CSS 2.1 9.5.
Below are listed (informatively) some implications of these rules:
<ul>
<li>
Boxes (including tables) fulfilling layout constraints at their
<a lt='stretch-fit size'>stretch-fit</a> or percentage-based size
may change <a>inline size</a> across pages.
<li>
Boxes (including tables) fulfilling layout constraints at their
<a lt="min-content size">min-content</a>, <a lt="max-content size">max-content</a>, or absolute-length size
will maintain their <a>inline size</a> across pages.
<li>
A block-level continuation fragment may be placed
below the top of the page if,
e.g. it establishes a block formatting context and
is placed beside a float
and both it and the float continue onto a narrower page
that is too narrow to hold both of them side-by-side.
<li>
An element adjacent to a preceding float on one page
may wind up above the float's continuation on the next page if,
e.g. that float is pushed down because
it no longer fits side-by-side with an earlier float
that also continues onto this narrower page.
<li>
A left float may appear on a page <em>before</em>
the remaining fragments of a preceding right float
if that right float does not fit on the earlier page.
However another right float will be forced down until
the preceding right float's remaining fragment can be placed.
</ul>
<div class="example">
Here is an example that shows the use of percentage-based progress:
Suppose we have an absolutely-positioned element that is positioned
''top: calc(150% + 30px)'' and has ''height: calc(100% - 10px)''. If
it is placed into a paginated context with a first page height of 400px,
a second page of 200px, and a third page of 600px, its layout progresses
as follows:
<ul>
<li>
First, the top position is resolved against
the height of the first page.
This results in 630px.
Since the first page has a height of only 400px,
layout moves to the second page,
recording progress of 400/630 = 63.49% with 36.51% left to go.
<li>
Now on the second page, the top position is again resolved,
this time against the height of the second page.
This results in 330px.
The remaining 36.51% of progress thus resolves to 120.5px,
placing the top edge of the element 120.5px down the second page.
<li>
Now the height is resolved against the second page;
it resolves to 190px.
Since there are only 79.5px left on the page,
layout moves to the third page,
recording progress of 79.5/190 = 41.84%, with 58.16% left to go.
<li>
On the third page, the height resolves to 590px.
The remaining 58.16% of progress thus resolves to 343.1px,
which fits on this page and completes the element.
</ul>
</div>
<h3 id="break-margins">
Adjoining Margins at Breaks: the 'margin-break' property</h3>
<pre class="propdef">
Name: margin-break
Value: auto | keep | discard
Initial: auto
Inherited: no
Applies to: all elements
Computed Value: specified keyword
Animation type: discrete
</pre>
Controls whether the box’s <a>block-axis</a> <a>margins</a>
are discarded or kept at a <a>fragmentation break</a>.
Values have the following meanings:
<dl dfn-for=margin-break dfn-type=value>
<dt><dfn>auto</dfn>
<dd>
When an <em>unforced</em> break occurs before or after the box,
any margins adjoining the break truncate to
the <a>remaining fragmentainer extent</a> before the break,
and are truncated to zero after the break.
When a <em>forced break</em> occurs there,
adjoining margins before the break are truncated,
but margins after the break are preserved.
<a href="https://www.w3.org/TR/css-break-4/#valdef-box-decoration-break-clone">Cloned margins</a>
are always truncated to zero.
Note: When margins collapse
(see <a href="https://www.w3.org/TR/CSS2/box.html#collapsing-margins">CSS2§8.3.1</a>),
the margins of multiple boxes can be adjoining the break.
<dt><dfn>keep</dfn>
<dd>
Margins adjoining a <a>fragmentation break</a>
are not truncated.
<dt><dfn>discard</dfn>
<dd>
Margins adjoining a <a>fragmentation break</a>
are always truncated,
including at the start and end of a <a>fragmentation context</a>.
</dl>
Note: See also the 'margin-trim' property,
which applies to the <a>fragmentation container</a> (page/column/etc.)
ISSUE: <a href="https://www.antennahouse.com/product/ahf66/ahf-focss6.html">Antenna House also allows a second <css>keep</css> keyword</a>,
which preserves the margin after the break;
it is otherwise discarded.
Do we want to include this feature?
Also, if only one ''keep'' is specified, does it apply only to the before margin or both sides?
See <a href="https://github.com/w3c/csswg-drafts/issues/3254">discussion</a>.
<div class="example">
Consider the following <a>multi-column layout</a> example:
<xmp>
<style>
article { columns: 16ch; border: solid silver; }
h3 { break-before: always; }
</style>
<article>
Here we can compare the effects of <code>margin-break</code>,
before and after forced and unforced breaks.
This paragraph starts after an unforced break.
<h3>This heading is given a forced break before.</h3>
</article>
</xmp>
Here are illustrations of how it might render
with each 'margin-break' value:
<figure>
<img src="images/margin-break-auto.png"
alt="Here the top margin is kept on the first paragraph and the heading
(which starts after a forced break)
but not after the second paragraph