forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOverview.bs
2222 lines (1871 loc) · 72.7 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 Regions Module Level 1
Status: ED
Work Status: Exploring
Shortname: css-regions
Level: 1
Group: csswg
TR: https://www.w3.org/TR/css-regions-1/
Previous Version: https://www.w3.org/TR/2014/WD-css-regions-1-20141009/
Previous Version: https://www.w3.org/TR/2014/WD-css3-regions-20140218/
ED: https://drafts.csswg.org/css-regions/
Editor: Rossen Atanassov, Microsoft Corporation, [email protected], w3cid 49885
Editor: Alan Stearns, Adobe Systems, Inc., [email protected], w3cid 46659
Former Editor: Vincent Hardy, Adobe Systems, Inc., [email protected]
!Issues list: <a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Regions&resolution=---&cmdtype=doit">In Bugzilla</a>
Abstract: The CSS Regions module allows content from one or more elements to flow through one or more boxes called CSS Regions, fragmented as defined in [[!CSS3-BREAK]]. This module also defines CSSOM to expose both the inputs and outputs of this fragmentation.
Link Defaults: css2 (property) max-height, dom-core-ls (interface) range
Ignored Terms: document, element, eventtarget
</pre>
<h2 id="introduction">
Introduction</h2>
<em>This section is non-normative.</em>
The core concept behind CSS Regions
is the ability to say,
"Display <em>this</em> content (a <a>named flow</a>)
over <em>there</em> (a <a>region chain</a>)."
The simplest example is:
<div class="example">
<pre><code>
#this {
flow-into: my-flow;
}
#there {
flow-from: my-flow;
}
</code></pre>
</div>
These two declarations will take
the element that matches <code>#this</code>,
put it into a flow named "my-flow",
and display the contents of "my-flow"
in the box from the element that matches <code>#there</code>.
This example has a single content source for the <a>named flow</a>,
and a single box for the <a>region chain</a>.
<a>Named flows</a> can also have multiple sources
and use multiple boxes for the <a>region chain</a>.
The <a>named flow</a> mechanism can be used
in several different ways -
some of which are
custom overflow handling,
aggregating content,
linked display boxes,
magazine-style layout,
and flowing content through areas in a paginated view.
<div class="example">
Linked display boxes can be created
to display article content above and below
other content on a page.
Given markup like this:
<pre><code class="html">
<article> ...some content... </article>
<aside> ad or image content </aside>
</code></pre>
The <aside> content will be displayed
below all of the article content.
On a large screen the page might display without scrolling,
but on a small screen the <aside> content
might not be visible until the view scrolls.
If it's important to show at least some
of the <aside> content in the initial view,
CSS Regions can fragment the article content across two boxes -
one above the <aside> and one below.
In this example (for simplicity's sake)
we create the boxes with additional elements:
<pre><code class="html">
<article> ...some content... </article>
<div class="top region"></div>
<aside> ad or image content </aside>
<div class="region"></div>
</code></pre>
<pre><code>
article {
flow-into: article-flow;
}
.region {
flow-from: article-flow;
}
.top {
max-height: 80vh;
}
</code></pre>
So the top box in the <a>region chain</a>
is limited to 80% of the viewport height.
If the article content doesn't fit in that box,
the article will continue
in the second box after the <aside> content.
<figure style="float:left; margin:1em;">
<img alt="Article and aside rendering without CSS Regions"
src="images/linked-boxes-before.png"/>
<figcaption>
Rendering without CSS Regions
</figcaption>
</figure>
<figure style="float:left; margin:1em;">
<img alt="Article and aside rendering with CSS Regions"
src="images/linked-boxes-after.png"/>
<figcaption>
Rendering with CSS Regions
</figcaption>
</figure>
<p style="clear:left;">In the images above,
the gray area represents
the content below the screen edge
in the initial view.
This example links just two boxes together,
but more boxes could be added to the <a>region chain</a>
to regularly interleave other content with the article.
</div>
<div class="example">
Custom overflow handling can be accomplished by linking a separate overflow box. In this example, the overflow box is nestled inside a menu in the markup, and only displays if the menu is toggled.
<pre><code class="html">
<nav> ...some links... </nav>
<div class="menu">
<nav></nav>
...some more links...
</div>
</code></pre>
If the links in the main nav element are placed in a <a>named flow</a>, that flow can be directed through both the main nav element and the overflow nav box in the menu:
<pre><code>
nav a {
flow-into: nav-link-flow;
}
nav {
flow-from: nav-link-flow;
}
</code></pre>
Then the main nav element and the menu can be arranged with constraints such that when the screen is too narrow for the main nav element to display all of the navigation links, the overflow moves to the menu.
<figure>
<img alt="Wide nav bar showing all of the links"
src="images/menu-wide.png"/>
<figcaption>
Wide rendering with menu shown
</figcaption>
</figure>
<figure>
<img alt="Narrow nav bar with some of the links in the menu"
src="images/menu-narrow.png"/>
<figcaption>
Narrow rendering with menu shown
</figcaption>
</figure>
</div>
<div class="example">
Since content is assigned to a <a>named flow</a> using a CSS selector, the content can come from multiple sources. The resulting aggregation can be displayed in a single box or flowed through multiple boxes as above.
So given this markup:
<pre><code class="html">
<div class="breaking-news"></div>
<article>News story</article>
<article class="breaking">Sports story</article>
<article>News story</article>
<article class="breaking">Entertainment story</article>
<article>Sports story</article>
</code></pre>
You can take the "breaking" stories and display them above all the others using two lines of CSS:
<pre><code>
.breaking {
flow-into: breaking-news;
}
.breaking-news {
flow-from: breaking-news;
}
</code></pre>
Given more data accessible to CSS selectors, you could rearrange the articles in other ways (sports on top, etc.) depending on the user's preferences.
</div>
<div class="note"><span class="note-prefix">Note </span>
<strong><a>CSS Regions</a> are independent from layout</strong>
Any of the CSS layout facilities can be used
to create, position and size boxes that can become <a>CSS Regions</a>.
The CSS Regions module does not
define a layout mechanism
and is meant to integrate
with existing and future CSS layout facilities.
</div>
<div class="note"><span class="note-prefix">Note </span>
<strong><a>CSS Regions</a> do not have to be elements</strong>
The CSS Regions module is independent
of the layout of boxes and
the mechanisms used to create them.
For simplicity,
our examples tend to
use elements to define the boxes.
Any other mechanism available
in markup or style
to create stylable boxes could be used instead,
such as pseudo-elements
or the @slot rule proposed
by the CSS Page Template Module [[CSS3-PAGE-TEMPLATE]].
The only requirement
for box to become a <a>CSS Region</a>
is that the 'flow-from' property applies to the box.
</div>
<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="css-regions-concepts">
CSS Regions concepts</h2>
<h3 id="regions">
Regions</h3>
A <dfn export>CSS Region</dfn>
is a block container
that has an associated
<em><a>named flow</a></em>
(see the 'flow-from' property).
<h3 id="region-chain-section">
Region chain</h3>
A <dfn export>region chain</dfn>
is the sequence of regions
that are associated with
a <a>named flow</a>.
<a>CSS Regions</a> in a
<a>region chain</a> receive content from the
<a>named flow</a> following their order in the chain.
<a>CSS Regions</a> are organized
into a <a>region chain</a>
according to the document order.
<h3 id=last-region>
Last region</h3>
A <a>CSS region</a> is deemed to be the <dfn lt="last usable region | last usable CSS region">last usable region</dfn>
in a <a>region chain</a>
if it is the first region in that chain to have <a>layout containment</a>,
or the last region in the chain if none of them have <a>layout containment</a>
(See [[!CSS-CONTAIN-1]]).
<h3 id="named-flow-section">
Named flows</h3>
A <dfn>named flow</dfn> is the ordered sequence of content
associated with a flow with a given identifier.
Contents in a <a>named flow</a> are ordered
according to the document order.
Content is placed into a <a>named flow</a>
with the 'flow-into' property.
The content in a <a>named flow</a> is laid out
in the <a>region chain</a>
that is associated with this <a>named flow</a>
using the 'flow-from' property.
Content from a <a>named flow</a>
is broken up between regions
according to the regions flow breaking rules.
A <a>named flow</a> is created when
some content is moved
into the flow with the given identifier
or when at least one <a>CSS Region</a>
requests content from that flow.
<h3 id="regions-flow-breaking-rules">
Regions flow breaking rules</h3>
Breaking a <a>named flow</a> across a <a>region chain</a>
is similar to breaking a document's content across pages
(see [[CSS3PAGE]])
or a multi-column container's content across column boxes
(see [[CSS3COL]]).
One difference is that page boxes are generated
based on the available content
whereas a <a>region chain</a> is a set of recipient boxes
for the <a>named flow</a> content
whose dynamic generation is not in the scope
of this specification.
Each <a>CSS Region</a> in turn
consumes content from its associated <a>named flow</a>.
The <a>named flow</a> content is positioned
in the current region
until a natural or forced region break occurs,
at which point the next region
in the <a>region chain</a>
becomes the current region.
If there are no more usable <a>CSS Regions</a>
in the <a>region chain</a>
and there is still content in the flow,
the positioning of the remaining content
is controlled by the 'region-fragment' property
on the <a>last usable CSS Region</a> in the chain.
The CSS regions module follows
the fragmentation rules defined
in the CSS Fragmentation Module Level 3
(see [[!CSS3-BREAK]]).
<h2 id="properties">
Properties</h2>
<h3 id="the-flow-into-property">
The 'flow-into' property</h3>
<div class="issue-marker wrapper">
<div class="issue-marker">
<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=16527">Issue-16527</a>
<div class="issue-details">
<p class="short-desc">[Shadow]: getFlowByName and shadow DOM</p>
</div>
</div>
</div>
The ‘flow-into’ property can place an element
or its contents
into a <a>named flow</a>.
Content that belongs to the same flow
is laid out in the <a>region chain</a>
associated with that flow.
<pre class='propdef'>
Name: flow-into
Value: none | <<ident>> [element|content]?
Initial: none
Applies To: All elements, but not <a href="https://www.w3.org/TR/selectors/#pseudo-elements">pseudo-elements</a> such as <code>::first-line</code>, <code>::first-letter</code>, <code>::before</code> or <code>::after</code>.
Inherited: no
Computed Value: as specified
Animation type: not animatable
</pre>
<dl>
<dt>none</dt>
<dd>
The element is not moved
to a <a>named flow</a>
and normal CSS processing takes place.
</dd>
<dt><a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a></dt>
<dd>
If the keyword <dfn>element</dfn> is present
or neither keyword is present,
then the element is taken out
of its parent's flow
and placed into the flow
with the name '<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>'.
If the keyword <dfn>content</dfn> is present,
then only the element's contents
are placed into the named flow.
The element or content is said to have
a <dfn id="specified-flow">specified flow</dfn>.
The values <code class=css>none</code>, <code class=css>inherit</code>, <code class=css>default</code>, <code class=css>auto</code> and <code class=css>initial</code>
are invalid flow names.
</dd>
</dl>
The 'flow-into' property affects
the visual formatting of elements or contents
placed into a <a>named flow</a>
and of the <a>region chain</a> laying out content
from a <a>named flow</a>.
The 'flow-into' property does not affect
the CSS cascade and inheritance
for the elements on which it is specified.
The 'flow-into' property does not affect the
<a href="https://www.w3.org/TR/2012/WD-dom-20120405/#introduction-to-the-dom">DOM</a>
[[!DOM]] position of an element or its contents.
The 'flow-into' property does not affect ordering
in non-visual media
(such as <a href="https://www.w3.org/TR/css3-speech/">speech</a>).
Likewise, 'flow-into' does not affect
the default traversal order
of sequential navigation modes
(such as cycling through links,
see e.g. <a href="https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex"><code>tabindex</code></a> [[HTML]]).
A <a>named flow</a> needs to be associated
with a <a>region chain</a>
(one or more <a>CSS Regions</a>)
for its content to be visually formatted.
If no <a>region chain</a> is associated
with a given <a>named flow</a>,
the content in the <a>named flow</a>
is not rendered:
it does not generate boxes
and is not displayed.
The children of an element or content
with a specified flow
may themselves have a specified flow,
in which case they become
the next sibling of the latest element
or content collected in that flow.
In some cases,
the child can become the next sibling
for one of its ancestors in the same flow.
Content in a <a>named flow</a>
is sequenced in document order.
The visual formatting model
uses the relationships between content
in the named flow as input,
rather than the contents’ position
in the DOM.
Each <a>CSS Region</a> in a <a>region chain</a>
establishes a containing block for absolutely positioned
elements in the <a>named flow</a> (see [[!CSS21]]).
That first <a>CSS Region</a> in a <a>region chain</a>
establishes the initial containing block for such absolutely
positioned elements.
<span>Regions</span> don't establish a containing block for
fixed positioned elements in the <a>named flow</a>.
Such fixed positioned elements are still positioned relative
to the viewport or the page area even if they have been
redirected into a named flow
The first region defines the principal
<a href="https://www.w3.org/TR/css3-writing-modes/#writing-mode">writing mode</a>
for the entire flow.
The writing mode
on subsequent regions is ignored.
If an element has <a>style containment</a> (See [[!CSS-CONTAIN-1]]),
then the 'flow-into' property must be <a for=property>scoped</a> to that element.
<div class="note"><span class="note-prefix">Note </span>
The 'flow-into' property moves an element into the flow
and the interplay with selectors should be considered carefully.
For example,
<pre>table {flow-into: table-content}</pre>
will move all tables in the "table-content"
<a>named flow</a>.
However, the
<pre>table > * {flow-into: table-content} ...</pre>
selector will move all immediate children
of all table elements
into the "table-content" <a>named flow</a>
(which may be useful as it will usually result,
if the immediate children are rows,
in merging rows of multiple tables),
but the
<pre>table * {flow-into: table-content}</pre>
selector will move all descendants
of table elements into the "table-content" <a>named flow</a>,
transforming the element tree
into a flat list in order of opening tags
(which is probably not intentional).
This will make all the descendants
of table elements siblings
in the <a>named flow</a>.
Having the descendants become siblings
in the <a>named flow</a>
results in a different processing
(see <a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/tables.html#anonymous-boxes">CSS 2.1's anonymous table objects</a>).
This note illustrates how authors must exercise caution
when choosing a particular selector
for setting the 'flow-into' property
to avoid unintended results.
</div>
<div class="note"><span class="note-prefix">Note </span>
Another consequence of moving elements
into <a>named flows</a> is that surrounding whitespace
is not moved into the named flow.
If you have code like this:
<pre>
span {flow-into: span-content}
<span>one</span>
<span>two</span>
</pre>
Then the "span-content" named flow contents
will contain this:
<pre>
<span>one</span><span>two</span>
</pre>
Which will change the display
from "one two" to "onetwo".
If whitespace is significant,
then moving the parent
that contains the whitespace
to the named flow
is required.
</div>
<h3 id="flow-from">
The 'flow-from' property</h3>
The 'flow-from' property makes
a block container a region
and associates it with
a <a>named flow</a>.
<pre class='propdef'>
Name: flow-from
Value: <<ident>> | none
Initial: none
Applies To: Non-replaced <a href="https://www.w3.org/TR/CSS21/visuren.html#block-boxes">block containers</a>. <br/> This might be expanded in future versions of the specification to allow other types of containers to receive flow content.
Inherited: no
Computed Value: as specified
Animation type: not animatable
</pre>
<dl>
<dt><strong>none</strong></dt>
<dd>
The block container is not a <a>CSS Region</a>.
</dd>
<dt><strong><a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a></strong></dt>
<dd>
The block container becomes a <a>CSS Region</a>
(except as detailed in the text below),
and is ordered in a <a>region chain</a>
according to its document order.
The content from the flow
with the <a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>
name will be <a href="#region-flow-break">broken
into fragments</a> and visually formatted in the
<a href="https://www.w3.org/TR/CSS21/visuren.html#principal-box">principal boxes</a>
of the <span>regions</span>
in the <a>region chain</a>.
<br/>
If there is no flow with name
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>,
then the block container does not
format any content visually.
</dd>
</dl>
If the 'content' property computes
to something else than ''content/normal''
(or ''content/none'' for a pseudo-element),
the block container does not become
a <a>CSS Region</a>.
If the 'display' property
of the block container
or one of its ancestors
computes to ''display/none'',
the block container does not become
a <a>CSS Region</a>.
A <a>CSS Region</a>’s document children
are not visually formatted
unless they are directed
to a <a>named flow</a>
with an associated <a>region chain</a>.
Block container pseudo-elements where
the value of 'flow-from' computes to an
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>
and the value of 'content' computes to ''content/none''
are generated as <a>CSS Regions</a>,
which is an update to the behavior
described in [[!CSS21]].
If an element has <a>style containment</a> (See [[!CSS-CONTAIN-1]]),
then the 'flow-from' property must be <a for=property>scoped</a> to that element.
<div class="note"><span class="note-prefix">Note </span>
A block container becomes a <a>CSS Region</a>
when its 'flow-from' property is set
to a valid <a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a> value,
even if there is no content contributing
to the referenced flow.
For example:
<pre>
<style>
.article{
flow-into: thread;
}
.region{
flow-from: thread;
}
</style>
<html>
<body>
<div class=region>div content</div>
</body>
</html>
</pre>
There is no element matching
the <code>.article</code> selector
and therefore no content
in the <code>thread</code> flow.
However, the block container matching
the <code>.region</code> selector
is still associated with
that empty <a>named flow</a>
and, consequently,
its children are not formatted visually.
</div>
<div class=note><span class=note-prefix>Note </span>
At the time of this note-writing, the <code>display</code> values that
always result in a non-replaced block container include
<code>block</code>, <code>inline-block</code>, <code>table-cell</code>,
<code>table-caption</code>, and <code>list-item</code>. All of these
display values work as regions with non-replaced elements.
The <code>flex</code> and <code>grid</code> display values do not
result in block containers (they are defined as flex containers and grid
elements, respectively). So ‘<a href="#flow-from"><code
class=property>flow-from</code></a>’ combined with those display values
does not result in a <a>CSS Region</a>.
</div>
<a>CSS Regions</a>
create a new
<a href="https://www.w3.org/TR/CSS2/visuren.html#z-index">stacking context</a>.
<a>CSS Regions</a>
establish a new
<a href="https://www.w3.org/TR/CSS2/visuren.html#block-formatting">block formatting Context</a>.
Exclusions (see [[CSS3-EXCLUSIONS]])
potentially impact the content
laid out in <a>region chains</a>,
just as for non-regions.
<div class="note"><span class="note-prefix">Note </span>
With <a>region chains</a>,
an element may be split across multiple boxes
and these boxes may overlap
(for example if they are absolutely positioned).
So fragments of the same element
can overlap each other.
Since each element has a single z-index,
it would be required to find another mechanism
to decide in which order
the fragments are rendered.
Since each <a>CSS Region</a> creates
a new stacking context,
it is clear that each fragment is rendered separately
and their rendering order follows
the regular CSS rendering model.
Fragments rendering separately
is also relevant to elements that might normally
be rendered as a unit
(for example,
an element with its own stacking context,
or with transparency).
Each fragment of these elements
is separately contained in the stacking context
created by the <a>CSS Region</a>,
so each fragment of these elements
is rendered separately.
</div>
See the
<a href="#regions-visual-formatting-details">regions visual formatting details</a>
section for a description of how
'width' and 'height' values are resolved
for <a>CSS Region</a> boxes.
<h4 id="circular-dependencies">
Cycle Detection</h4>
<a>named flows</a> containing elements
where the value of 'flow-from' computes to an
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>
can produce nonsensical circular relationships,
such as a <a>named flow</a>
containing <a>CSS Regions</a>
in its own <a>region chain</a>.
These relationships can be easily
and reliably detected and resolved, however,
by keeping track of a dependency graph
and using common cycle-detection algorithms.
The dependency graph consists of edges such that:
<ul>
<li>
Every <a>named flow</a> depends on its elements
where the value of 'flow-from' computes to an
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>.
</li>
<li>
Every element in a <a>named flow</a>
where the value of 'flow-from' computes to an
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>
depends on the <a>named flow</a> with the
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>
name.
</li>
</ul>
If the graph contains a cycle,
any elements where the value of 'flow-from'
computes to an
<a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-identifier"><ident></a>
participating in the cycle
do not become <a>CSS Regions</a>.
<div class="note"><span class="note-prefix">Note </span>
For example, styling like this:
<pre>
#id {
flow-into: foolish;
flow-from: foolish;
}
</pre>
would move the <code>#id</code> element to a "foolish" <a>named flow</a>,
and try to make the <code>#id</code> element
a <a>CSS Region</a> for the "foolish" <a>named flow</a>.
The "foolish" <a>named flow</a> would then contain its own region,
creating a cycle.
So the <code>#id</code> element does not become a <a>CSS Region</a>.
</div>
<div class="note"><span class="note-prefix">Note </span>
The content keyword can be used to break cycles in some circumstances:
<pre>
#id {
flow-into: not-so-foolish content;
flow-from: not-so-foolish;
}
</pre>
Here only the contents of the <code>#id</code> element are moved to the <a>named flow</a>, and the box for the <code>#id</code> element <em>does</em> become a <a>CSS Region</a>. Since the <a>named flow</a> does not contain the element itself, there is no cycle. With this declaration the <code>#id</code> element becomes a single-box <a>region chain</a> for its contents, and other boxes could be added to the chain to customize overflow.
</div>
<h4 id="fragmenting-regions">
Nested fragmentation contexts</h4>
A <a>CSS Region</a> that contains
a fragment of a <a>named flow</a>
can itself be fragmented if it is nested
within a fragmentation context [[!CSS3-BREAK]],
such as when a layout
using a <a>region chain</a> is printed.
In these cases break opportunities
in the named flow fragment
contained by the <a>CSS Region</a>
are determined using the standard
<a href="https://www.w3.org/TR/css3-break/">fragmentation rules</a>.
In other words,
each region box and its associated fragment
should break as if it were a simple div
containing the fragment contents.
This can be controlled by using
an avoid break value on the <a>CSS Region</a>,
if that is desired.
A <a>CSS Region</a> can be part
of the contents of a separate named flow,
as long as there are no cycles broken
by the <a href="#circular-dependencies">Cycle Detection</a>
described above.
This case is a <dfn>nested region context</dfn>,
which has an effect
on the <a href="#regions-visual-formatting-steps">Visual Formatting Steps</a>
described below.
<h3 id="region-flow-break">
Controlling Region Flow Breaks</h3>
Fragmentation across regions can be controlled with the
'break-inside', 'break-before', and 'break-after' properties:
the generic values ''break-before/auto'', ''break-before/always'', and ''break-before/avoid''
affect content flowed through regions just as they do content flowed through columns or pages,
and the ''break-before/region'' and ''break-before/avoid-region'' values
provide region-specific breaking controls.
See [[CSS3-BREAK]] for details.
<h3 id="the-region-fragment-property">
The region-fragment property</h3>
<pre class='propdef'>
Name: region-fragment
Value: auto | break
Initial: auto
Applies To: <a>CSS Regions</a>
Inherited: no
Computed Value: specified keyword
Animation type: discrete
</pre>
ISSUE: The 'continue' property in [[css-overflow-3]] is likely to replace this property.
The 'region-fragment' property controls the behavior
of the <a>last usable region</a>
associated with a <a>named flow</a>.
<dl>
<dt>auto</dt>
<dd>
Content flows as it would in a regular content box.
If the content exceeds the container box,
it is subject to the
<a href= "https://www.w3.org/TR/CSS21/visufx.html#propdef-overflow">overflow</a>
property's computed value on the <a>CSS Region</a>.
Region breaks must be ignored on the <a>last usable region</a>.
</dd>
<dt>break</dt>
<dd>
If the content fits within the <a>CSS Region</a>,
then this property has no effect.
If the content does not fit within the <a>CSS Region</a>,
the content breaks as if flow was going to continue in a subsequent region.
See the <a href= "#regions-flow-breaking-rules">breaking rules</a> section.
A forced region break takes precedence over a natural break point.
Flow content that follows the last break in the <a>last usable region</a> is not rendered.
</dd>
</dl>
The 'region-fragment' property does not influence
the size of the region it applies to.
The following code sample illustrates
the usage of the 'region-fragment' property.
<div class="example">
<pre>
<style>
article {
flow-into: article-flow;
}
#region-1, #region-2 {
flow-from: article-flow;
<strong>region-fragment: break;</strong> /* or auto */
<strong>overflow: visible;</strong> /* or hidden */
}
</style>
<body>
<article>...</article>
<div id="region-1"></div>
<div id="region-2"></div>
</body>
</pre>
</div>
<figure>
<table style="border: 1px solid gray;width: 100%;">
<tr>
<td>article with two<br>
overflowing lines</td>
<td><code>region-fragment: break<br>
overflow: visible</code></td>
<td><code>region-fragment: auto<br>
overflow: visible</code></td>
</tr>
<tr>
<td rowspan="3" style="vertical-align: top;"><img src=
"images/region-overflow-flow.png" alt=
"flow content rendering"></td>
<td><img src="images/region-overflow-break-visible.png" alt=
"rendering with region-fragment:break and overflow:visible"></td>
<td><img src="images/region-overflow-auto-visible.png"
alt="rendering with region-fragment:auto and overflow:visible"></td>
</tr>
<tr>
<td><code>region-fragment: break<br>
overflow: hidden</code></td>
<td><code>region-fragment: auto<br>
overflow: hidden</code></td>
</tr>
<tr>
<td><img src="images/region-overflow-break-hidden.png" alt=
"rendering with region-fragment:break and overflow:hidden"></td>
<td><img src="images/region-overflow-auto-hidden.png"
alt="rendering with region-fragment:auto and overflow:hidden"></td>
</tr>
</table>
<figcaption>
Combinations of region-fragment and overflow.
</figcaption>
</figure>
<div class="note"><span class="note-prefix">Note </span>
The 'overflow' property is honored on a region:
if region content overflows,
such as the borders of elements
on the last line,
the 'overflow' property controls
the visibility of the overflowing content.
See the 'overflow' property definition ([[CSS21]]).
</div>
<h2 id="cssom_view_and_css_regions">
CSSOM</h2>
Since content may flow into multiple regions,
authors need a way to determine if there are enough regions
to flow all the content from a named flow.
This is especially important considering that the size of regions
or the size of the content may change depending on the display context.
For example,
flowing the same content on a mobile phone with a small screen
may require more regions than on a large desktop display.
Another example is the user changing
the font size of text flowing through regions.
Depending on the change,
new regions may be needed to accommodate for the additional space required
to fit the larger text or some regions may need to be removed for smaller text.