forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverview.bs
1491 lines (1264 loc) · 53.1 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 Overflow Module Level 4
Status: ED
Work Status: Revising
ED: https://drafts.csswg.org/css-overflow-4/
Shortname: css-overflow
Group: csswg
Level: 4
TR: https://www.w3.org/TR/css-overflow-4/
Editor: L. David Baron, Mozilla https://www.mozilla.org/, https://dbaron.org/, w3cid 15393
Editor: Florian Rivoal, On behalf of Bloomberg, http://florian.rivoal.net/, w3cid 43241
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Abstract: This module contains the features of CSS relating to scrollable overflow handling in visual media.
It builds on the <a href="https://www.w3.org/TR/css-overflow-3/">CSS Overflow Module Level 3</a>,
defining
'line-clamp', its longhands, and its legacy pre-standard syntax;
adding a 'block-ellipsis' property;
and expanding 'overflow-clip-margin' with longhands.
</pre>
<pre class="link-defaults">
type: dfn; spec:css-multicol-1; text:overflow column
spec:css-pseudo-4; type:selector; text:::first-letter
spec:css-pseudo-4; type:selector; text:::first-line
spec:css-writing-modes-4; type:dfn; text:start
spec:css-writing-modes-4; type:dfn; text:end
</pre>
<pre class="anchors">
url: https://drafts.csswg.org/selectors-3/#subject; type: dfn; text: subject;
url: https://www.w3.org/TR/CSS21/visudet.html#strut; type: dfn; text: strut;
</pre>
<style>
table.source-demo-pair {
width: 100%;
}
.in-cards-demo {
width: 13em;
height: 8em;
padding: 4px;
border: medium solid blue;
margin: 6px;
font: medium/1.3 Times New Roman, Times, serif;
white-space: nowrap;
}
.bouncy-columns-demo {
width: 6em;
height: 10em;
float: left;
margin: 1em;
font: medium/1.25 Times New Roman, Times, serif;
white-space: nowrap;
}
.bouncy-columns-demo.one {
background: aqua; color: black;
transform: rotate(-3deg);
}
.bouncy-columns-demo.two {
background: yellow; color: black;
transform: rotate(3deg);
}
.article-font-inherit-demo {
font: 1em/1.25 Times New Roman, Times, serif;
white-space: nowrap;
}
.article-font-inherit-demo.one {
width: 12em;
font-size: 1.5em;
margin-bottom: 1em;
height: 4em;
}
.article-font-inherit-demo.two {
width: 11em;
margin-left: 5em;
margin-right: 2em;
}
.dark-columns-demo {
width: 6em;
height: 10em;
float: left;
margin-right: 1em;
font: medium/1.25 Times New Roman, Times, serif;
white-space: nowrap;
}
.dark-columns-demo.one {
background: aqua; color: black;
}
.dark-columns-demo.one :link {
color: blue;
}
.dark-columns-demo.one :visited {
color: purple;
}
.dark-columns-demo.two {
background: navy; color: white;
}
.dark-columns-demo.two :link {
color: aqua;
}
.dark-columns-demo.two :visited {
color: fuchsia;
}
.article-max-lines-demo {
font: 1em/1.25 Times New Roman, Times, serif;
white-space: nowrap;
}
.article-max-lines-demo.one::first-letter {
font-size: 2em;
line-height: 0.9;
}
.article-max-lines-demo.one {
font-size: 1.5em;
width: 16em;
}
.article-max-lines-demo.two {
width: 11.5em;
float: left; margin-right: 1em;
}
.article-max-lines-demo.three {
width: 11.5em;
float: left;
}
.awesome-table td { padding: 5px; }
.awesome-table {
color: #000;
background: #fff;
margin: auto;
}
</style>
<h2 id="intro">
Introduction</h2>
This specification extends [[!CSS-OVERFLOW-3]].
It contains several primary sections:
: [[#overflow-properties|Overflow Scrolling and Clipping Controls]]
::
This section defines relatively simple extensions to the 'overflow-*' properties [[css-overflow-3#overflow-properties|in Level 3]].
: [[#auto-ellipsis|Automatic Ellipses]].
::
This section defines some experimental extensions to the '*-ellipsis' properties [[css-overflow-3#auto-ellipsis|in Level 3]].
Note: At the time of writing, [[CSS-OVERFLOW-3]] is not completely finalized yet.
To avoid accidental divergences and maintenance overhead,
This specification is written as a delta specification over css-overflow Level 3.
Once the level 3 specification is final,
its content will be integrated into this specification,
which will then replace it.
Until then, this specification only contains additions and extensions to level 3.
<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.
<h3 id="placement">
Module Interactions</h3>
This module extends features defined in [[!CSS-OVERFLOW-3]].
<h2 id="overflow-concepts">
Overflow Concepts and Terminology</h2>
Issue: Copy [[css-overflow-3#overflow-concepts|Level 3 content]] when final.
<h2 id="overflow-properties">
Scrolling and Clipping Overflow</h2>
Issue: Copy [[css-overflow-3#overflow-properties|Level 3 content]] when final.
<h3 id="overflow-control">
Managing Overflow: the 'overflow-x', 'overflow-y', and 'overflow' properties</h3>
This level extends the 'overflow-x' and 'overflow-y' properties
(and 'overflow' [=shorthand=])
to apply to [=replaced elements=].
On [=replaced elements=],
the [=used values=]
of all computed values other than ''overflow/visible''
is ''overflow/clip''.
Host languages should define [=UA style sheet=] rules
that apply a default value of ''overflow/clip'' to such elements
and set their 'overflow-clip-margin' to ''overflow-clip-margin/content-box''.
Note: Application of 'overflow' to [=replaced elements=] was added
to allow images to paint effects outside their effective layout box;
the recommended UA style sheet rules are to effect their original behavior as a default.
See discussion in <a href="https://github.com/w3c/csswg-drafts/issues/7058">Issue 7059</a>
and <a href="https://github.com/w3c/csswg-drafts/issues/7144">Issue 7144</a>.
This is a change from <a href="https://www.w3.org/TR/CSS2/">CSS2.1</a>
and is at-risk.
ISSUE(7144): Application of 'overflow' to [=replaced elements=]
is still being worked out.
<h3 id="overflow-clip-margin">
Expanding Clipping Bounds: the 'overflow-clip-margin-*' properties</h3>
<pre class="propdef shorthand">
Name: overflow-clip-margin-top, overflow-clip-margin-right, overflow-clip-margin-bottom, overflow-clip-margin-left, overflow-clip-margin-block-start, overflow-clip-margin-inline-start, overflow-clip-margin-block-end, overflow-clip-margin-inline-end
Value: <<visual-box>> || <<length [0,∞]>>
Initial: ''0px''
Inherited: no
Logical property group: overflow-clip-margin
Applies to: boxes to which 'overflow' applies
Computed value: the computed <<length>> and a <<visual-box>> keyword
Animation type: per computed value if the <<visual-box>> values match; otherwise discrete
</pre>
<pre class="propdef shorthand">
Name: overflow-clip-margin, overflow-clip-margin-inline, overflow-clip-margin-block
Value: <<visual-box>> || <<length [0,∞]>>
Initial: ''0px''
Inherited: no
Applies to: boxes to which 'overflow' applies
</pre>
These properties and their shorthands
define the <dfn export>overflow clip edge</dfn> of the box,
i.e. precisely <em>how far</em> outside its bounds
the box’s content is allowed to paint
before being clipped
by effects (such as ''overflow: clip'', above)
that are defined to clip to the box’s [=overflow clip edge=].
The [=shorthand=]/[=longhand=] relationships are as for 'margin',
but note that the [=shorthands=] have a restricted syntax.
Values are defined as follows:
<dl dfn-type=value dfn-for=overflow-clip-margin>
: <dfn><<visual-box>></dfn>
::
Specifies the box edge to use as the [=overflow clip edge=] origin,
i.e. when the specified offset is zero.
If omitted,
defaults to ''overflow-clip-margin/padding-box'' on non-[=replaced=] elements,
or ''overflow-clip/content-box'' on [=replaced=] elements.
ISSUE(7144): Application of 'overflow-clip-margin' to [=replaced elements=]
is still being worked out.
: <dfn><<length [0,∞]>></dfn>
::
The specified offset dictates
how much the [=overflow clip edge=] is expanded from
the specified box edge
Negative values are invalid.
Defaults to zero if omitted.
</dl>
The [=overflow clip edge=] is shaped in the corners
exactly the same way as an <a spec=css-backgrounds-3>outer box-shadow</a>
with a spread radius of the same cumulative offset
from the box’s [=border edge=].
See [[css-backgrounds-3#corner-shaping]]
and [[css-backgrounds-3#shadow-shape]],
noting in particular the formula for outsets beyond the [=border edge=].
Note: This property has no effect on boxes
with ''overflow: hidden'' or ''overflow: scroll'',
which are not defined to use the [=overflow clip edge=].
<h2 id="auto-ellipsis">
Automatic Ellipses</h2>
<h3 id="text-overflow" caniuse="text-overflow">
Inline Overflow Ellipsis: the 'text-overflow' property</h3>
<pre class="propdef">
Name: text-overflow
Value: [ clip | ellipsis | <<string>> | fade | <<fade()>> ]{1,2}
Initial: clip
Applies to: block containers
Inherited: no
Percentages: refer to the width of the line box
Computed value: as specified, with lengths made absolute
Animation type: by computed value type
</pre>
ISSUE: This section might need to be re-synced against [[CSS-OVERFLOW-3]].
This property specifies rendering when inline content overflows
its line box edge
in the inline progression direction of its block container element ("the block")
that has 'overflow'
other than ''overflow/visible''.
Even though this property is not inherited,
anonymous block container boxes generated to
establish the line box's <a>inline formatting context</a> (see [=block container=])
are ignored,
and the value of the property that applies is the one
on the non anonymous box.
<span class=note>This can be seen in the “nested paragraph” part of <a href="#example-44082941">example 7</a>:
even though the word “NESTED” is wrapped in an anonymous block container
whose 'text-overflow' property has the initial value,
it is ellipsed.</span>
Text can overflow for example when it is prevented from wrapping
(e.g. due to <code class="lang-css">white-space: nowrap</code>
or a single word is too long to fit).
Values have the following meanings:
<dl dfn-for="text-overflow" dfn-type=value>
<dt><dfn id=overflow-clip>clip</dfn>
<dd>
Clip inline content that overflows its block container element.
Characters may be only partially rendered.
<dt><dfn id=overflow-ellipsis>ellipsis</dfn>
<dd>
Render an ellipsis character (U+2026)
to represent clipped inline content.
Implementations may substitute a more language, script, or writing-mode appropriate
ellipsis character,
or three dots "..." if the ellipsis character is unavailable.
<dt id=overflow-string><<string>>
<dd>
Render the given string to represent clipped inline content.
The given string is treated as an independent paragraph
for bidi purposes.
<dt dfn-type=function><dfn>fade( [ <<length-percentage>> ] )</dfn>
<dd>
Clip inline content that overflows its line box.
Characters may be only partially rendered.
In addition, the UA must apply a fade out effect
near the edge of the line box,
reaching complete transparency at the edge.
Issue: Do we need to define the way
the fade out is calculated
so that the fading is identical across browsers?
It should probably be something like
''mask-image: linear-gradient(to right, rgba(0,0,0,1), rgba(0,0,0,0))'',
except applied to the relevant portion of the line only.
The argument determines the distance
over which the fade effect is applied.
The <<percentage>> is resolved against the width of the line box.
Values lower than 0 are clipped to 0.
Values greater than the width of the line box are clipped to the width of the line box.
Issue: If the line box is too short
to display the fade effect at the desired length,
should we drop the effect,
or shrink the distance it is applied over until it fits,
or clip the end of the fade?
Issue: How should we deal with
things overflowing out of the line box,
or overlapping onto it?
Should fade apply to the logical content of the line,
or to the physical area of the line box,
or the intersection of both?
<dt><dfn>fade</dfn>
<dd>
Same as ''fade()'',
but the distance over which the fading effect is applied
is determined by the UA.
''1em'' is suggested as a reasonable value.
</dl>
The term "character" is used in this property definition
for better readability and means "grapheme cluster" [[!UAX29]]
for implementation purposes.
If there is one value,
it applies only to the <a>end</a> line box edge.
If there are two values,
the first value applies to the <a>line-left</a> edge,
and the second value applies to the <a>line-right</a> edge.
The terms <a>end</a>, <a>line-left</a> and <a>line-right</a> are defined in [[!CSS-WRITING-MODES-3]].
Note: the use of <a>line-left</a> and <a>line-right</a>
rather than <a>start</a> and <a>end</a>
when there are two values is intentional,
to facilitate the use of directional characters such as arrows.
For the ellipsis
and string values,
implementations must hide characters and
<a href="https://www.w3.org/TR/CSS2/visuren.html#inline-boxes">
atomic inline-level elements</a>
at the applicable edge(s) of the line as necessary to fit the ellipsis/string, and
place the ellipsis/string immediately adjacent
to the applicable edge(s) of the remaining inline content.
The first character or
<a href="https://www.w3.org/TR/CSS2/visuren.html#inline-boxes">
atomic inline-level element</a>
on a line
must be clipped rather than ellipsed.
<div class=example>
<h3 id="bidi-ellipsis" class="no-num no-toc">Bidi ellipsis examples</h3>
These examples demonstrate which characters get hidden
to make room for the ellipsis in a bidi situation:
those visually at the edge of the line.
Sample CSS:
<pre><code highlight=css>
div {
font-family: monospace;
white-space: pre;
overflow: hidden;
width: 9ch;
text-overflow: ellipsis;
}
</code></pre>
Sample HTML fragments, renderings, and your browser:
<table class="awesome-table data">
<thead><th>HTML<th>Reference rendering<th>Your Browser</thead>
<tr>
<td><code highlight=html><div>שלום 123456</div></code><td><div style="font-family:monospace">123456 ם…</div><td><div style="font-family: monospace; white-space: pre; overflow: hidden; width: 9ch; text-overflow: ellipsis">שלום 123456</div>
<tr><td><code highlight=html><div dir=rtl>שלום 123456</div></code><td><div style="font-family:monospace">…456 שלום</div><td><div style="font-family: monospace; white-space: pre; overflow: hidden; width: 9ch; text-overflow: ellipsis" dir=rtl>שלום 123456</div>
</table>
</div>
<h3 id="ellipsing-details" class="no-num no-toc">
ellipsing details</h3>
<ul>
<li>
Ellipsing only affects rendering and must not affect layout
nor dispatching of pointer events:
The UA should dispatch any pointer event on the ellipsis to the elided element,
as if 'text-overflow' had been ''text-overflow/none''.
<li>
The ellipsis is styled and baseline-aligned according to the block.
<li>
Ellipsing occurs after relative positioning and other graphical transformations.
<li>
If there is insufficient space for the ellipsis,
then clip the rendering of the ellipsis itself
(on the same side that neutral characters on the line
would have otherwise been clipped with the ''text-overflow:clip'' value).
</ul>
<h3 id="ellipsis-interaction" class="no-num no-toc">
user interaction with ellipsis</h3>
<ul>
<li>
When the user is interacting with content
(e.g. editing, selecting, scrolling),
the user agent may treat ''text-overflow/ellipsis'', string values, ''overflow-text/fade'' or ''overflow-text/fade()'' as ''text-overflow:clip''.
<li>
Selecting the ellipsis should select the ellipsed text.
If all of the ellipsed text is selected,
UAs should show selection of the ellipsis.
Behavior of partially-selected ellipsed text is up to the UA.
</ul>
<div class="example">
<h3 id="text-overflow-examples" class="no-num no-toc">text-overflow examples</h3>
These examples demonstrate setting the text-overflow of a block container element
that has text which overflows its dimensions:
sample CSS for a div:
<pre><code class="lang-css">
div {
font-family: Helvetica, sans-serif;
line-height: 1.1;
width: 3.1em;
border: solid .1em black;
padding: 0.2em; margin:1em 0;
}
</code></pre>
sample HTML fragments, renderings, and your browser:
<table class="awesome-table"><tbody>
<tr>
<th>HTML
<th>sample rendering
<th>your browser
<tr>
<td>
<pre><code class="lang-markup">
<div>
CSS IS AWESOME, YES
</div>
</code></pre>
<td>
<object type="image/png" data="images/cssisawesome.png">
First, a box with text drawing outside of it.
</object>
<td>
<div style="width:3.1em; border:solid .1em black; margin:1em 0; padding:.2em; font-family:Helvetica,sans-serif; line-height:1.1;">CSS IS AWESOME, YES</div>
<tr>
<td>
<pre><code class="lang-markup">
<div style="<strong>text-overflow:clip;</strong> overflow:hidden">
CSS IS AWESOME, YES
</div>
</code></pre>
<td>
<object type="image/png" data="images/cssisaweso.png">
Second, a similar box with the text clipped outside the box.
</object>
<td>
<div style="width:3.1em; border:solid .1em black; margin:1em 0; padding:.2em; font-family:Helvetica,sans-serif; line-height:1.1; overflow:hidden;text-overflow:clip;">CSS IS AWESOME, YES</div>
<tr>
<td>
<pre><code class="lang-markup">
<div style="<strong>text-overflow:ellipsis;</strong> overflow:hidden">
CSS IS AWESOME, YES
</div>
</code></pre>
<td>
<object type="image/png" data="images/cssisaw.png">
Third, a similar box with an ellipsis representing the clipped text.
</object>
<td>
<div style="width:3.1em; border:solid .1em black; margin:1em 0; padding:.2em; font-family:Helvetica,sans-serif; line-height:1.1; overflow:hidden;text-overflow:ellipsis;">CSS IS AWESOME, YES</div>
<tr>
<td>
<pre><code class="lang-markup">
<div style="<strong>text-overflow:ellipsis;</strong> overflow:hidden">
NESTED
<p>PARAGRAPH</p>
WON'T ELLIPSE.
</div>
</code></pre>
<td>
<object type="image/png" data="images/nes.png">
Fourth, a box with a nested paragraph demonstrating anonymous block boxes equivalency and non-inheritance into a nested element.
</object>
<td>
<div style="width:3.1em; border:solid .1em black; margin:1em 0; padding:.2em; font-family:Helvetica,sans-serif; line-height:1.1; overflow:hidden;text-overflow:ellipsis;">NESTED
<p>PARAGRAPH</p>
WON'T ELLIPSE.</div>
<tr>
<td>
<pre><code class="lang-markup">
<div style="<strong>text-overflow:fade;</strong> overflow:hidden">
CSS IS AWESOME, YES
</div>
</code></pre>
<td>
<object type="image/png" data="images/cssisfade.png">
a box with the text fading out on overflow.
</object>
<td>
<div style="width:3.1em; border:solid .1em black; padding:.2em; font-family:Helvetica,sans-serif; line-height:1.1; overflow:hidden;text-overflow:clip;">CSS IS AWESOME, YES</div>
</tbody></table>
</div>
Note: the side of the line that the ellipsis is placed depends on the 'direction' of the block.
E.g. an overflow hidden right-to-left
(<code class="lang-css">direction: rtl</code>)
block clips inline content on the <a spec=css-writing-modes-3>left</a> side,
thus would place a text-overflow ellipsis on the <a spec=css-writing-modes-3>left</a>
to represent that clipped content.
Issue: insert RTL example diagram here to illustrate note.
<h3 id="ellipsis-scrolling" class="no-num no-toc">
ellipsis interaction with scrolling interfaces</h3>
This section applies to elements with text-overflow other than ''text-overflow:clip''
(non-clip text-overflow)
and overflow:scroll.
When an element with non-clip text-overflow has overflow of scroll
in the inline progression dimension of the text,
and the browser provides a mechanism for scrolling
(e.g. a scrollbar on the element,
or a touch interface to swipe-scroll, etc.),
there are additional implementation details that provide a better user experience:
When an element is scrolled (e.g. by the user, DOM manipulation),
more of the element's content is shown.
The value of text-overflow should not affect
whether more of the element's content is shown or not.
If a non-clip text-overflow is set,
then as more content is scrolled into view,
implementations should show whatever additional content fits,
only truncating content which would otherwise be clipped
(or is necessary to make room for the ellipsis/string),
until the element is scrolled far enough
to display the edge of the content
at which point that content should be displayed
rather than an ellipsis/string.
<div class="example">
This example uses text-overflow on an element with overflow scroll
to demonstrate the above described behavior.
sample CSS:
<pre><code class="lang-css">
div.crawlbar {
text-overflow: ellipsis;
height: 2em;
overflow: scroll;
white-space: nowrap;
width: 15em;
border:1em solid black;
}
</code></pre>
sample HTML fragment:
<pre><code class="lang-markup">
<div class="crawlbar">
CSS is awesome, especially when you can scroll
to see extra text instead of just
having it overlap other text by default.
</div>
</code></pre>
demonstration of sample CSS and HTML:
<div style="text-overflow: ellipsis; height: 2em; overflow: scroll; white-space: nowrap; width: 15em; border:1em solid black;">
CSS is awesome, especially when you can scroll
to see extra text instead of just
having it overlap other text by default.
</div>
</div>
As some content is scrolled into view,
it is likely that other content may scroll out of view on the other side.
If that content's block container element is the same
that's doing the scrolling,
and the computed value of 'text-overflow' has two values, with
the value applying to the start edge being a non-clip value,
then implementations must render an ellipsis/string in place of
the clipped content,
with the same details as described in the value definition above,
except that the ellipsis/string is drawn in the <a>start</a>
(rather than <a>end</a>) of
the block's direction (per the direction property).
While the content is being scrolled,
implementations may adjust their rendering of ellipses/strings
(e.g. align to the box edges rather than line edges).
<div class="example">
Same as previous example except with <code>text-overflow: ellipsis ellipsis</code>, demonstrated:
<div style="text-overflow: ellipsis ellipsis; height: 2em; overflow: scroll; white-space: nowrap; width: 15em; border:1em solid black;">
CSS is awesome, especially when you can scroll
to see extra text instead of just
having it overlap other text by default.
</div>
</div>
If there is insufficient space for both start
and end ellipses/strings,
then only the end ellipsis/string should be rendered.
<h3 id="block-ellipsis">
Indicating Block-Axis Overflow: the 'block-ellipsis' property</h3>
<pre class=propdef>
Name: block-ellipsis
Value: none | auto | <<string>>
Initial: none
Applies to: [=block containers=]
Inherited: yes
Percentages: N/A
Computed value: specified value
Animation type: discrete
</pre>
This property allows inserting content into the last line box
before a (forced <em>or</em> unforced) <a>region break</a>
to indicate the continuity of truncated/interrupted content.
It only affects line boxes contained directly by the <a>block container</a> itself,
but as it inherits, will have an effect on descendants’ line boxes unless overridden.
If the box contains no line box immediately preceding a <a>region break</a>,
then this property has no effect.
Note: See [[css-overflow-4#fragmentation]] for a way to generate boxes with such a [=region break=].
ISSUE: Should this apply to other types of fragmentation breaks (e.g. pages, columns)?
The inserted content is called the <dfn>block overflow ellipsis</dfn>.
Values have the following meanings:
<dl dfn-for="block-ellipsis" dfn-type=value>
<dt><dfn>none</dfn>
<dd>
The rendering is unaffected.
<dt><dfn>auto</dfn>
<dd>
Render an ellipsis character (U+2026)--
or a more typographically-appropriate equivalent--
as the <a>block overflow ellipsis</a>
at the end of the affected line box.
UAs should use the conventions of the
<a>content language</a>,
writing system, and
<a>writing mode</a>
to determine the most appropriate ellipsis string.
<dt><dfn><<string>></dfn>
<dd>
Render the specified string
as the <a>block overflow ellipsis</a>
at the end of the affected line box.
The UA may truncate this string if it is absurdly long.
</dl>
When 'block-ellipsis' is not ''block-ellipsis/none'',
the <a>block overflow ellipsis</a> string
is wrapped in an anonymous inline
and placed at the end of the line box
as a direct child of the <a>block container</a>’s <a>root inline box</a>,
reducing the space in the line box
available to the other contents of the line.
This inline is assigned ''unicode-bidi: plaintext''
and ''line-height: 0''
and is placed in the line box after the last
<a>soft wrap opportunity</a> (see [[!CSS-TEXT-3]])
that would still allow the entire <a>block overflow ellipsis</a> to fit on the line.
For this purpose, <a>soft wrap opportunities</a> added by 'overflow-wrap' are ignored.
If this results in the entire contents of the line box being displaced,
the line box is considered to contain a [=strut=], as defined in [[CSS2/visudet#leading]].
Text <a href="https://www.w3.org/TR/css-text-3/#justification">alignment and justification</a>
occurs after placement,
and measures the inserted <a>block overflow ellipsis</a>
together with the rest of the line’s content.
Note: Setting the [=block overflow ellipsis=]'s 'line-height' to ''0''
makes sure that inserting it cannot cause the line's height to grow,
which could cause further relayouts and potentially cycles.
This is almost equivalent to inserting the [=block overflow ellipsis=]
as a paint-time operation, except that it still participates in alignment and justification.
The downside is that unusually tall / deep glyphs in the [=block overflow ellipsis=]
may overflow.
The [=block overflow ellipsis=] must not be included
in either the ''::first-letter'' nor the ''::first-line'' pseudo-elements.
If there is a subsequent <a>fragmentation container</a> in the [=fragmentation context=]
that would receive subsequent content,
then the content displaced by the <a>block overflow ellipsis</a>
must be pushed to that <a>fragmentation container</a>.
The UA must treat the <a>block overflow ellipsis</a> as an unbreakable string,
If any part of the [=block overflow ellipsis=] overflows,
it is treated as [=scrollable overflow=],
and its rendering is affected by the 'text-overflow' property.
The <a>block overflow ellipsis</a> does not capture events:
pointer events are dispatched to whatever is underneath it.
It also has no effect on the intrinsic size of the box:
its <a lt="min-content size">min-content</a> and <a lt="max-content size">max-content</a> sizes
are calculated exactly as if 'block-ellipsis' were ''block-ellipsis/none''.
Note: Future specifications may extend this feature,
for example by providing an ''::ellipsis'' pseudo-element
to style the text,
or by allowing the selection of a child element of the block
to use as either an inline-level or block-level indicator
(in which case, it can capture events).
<h2 id=fragmentating-overflow>
Fragmenting Overflow</h2>
<h3 id=line-clamp>
Limiting Visible Lines: the 'line-clamp' shorthand property</h3>
<pre class="propdef shorthand">
Name: line-clamp
Value: none | <<integer [1,∞]>> || <<'block-ellipsis'>>
Initial: none
Percentages: N/A
</pre>
The 'line-clamp' property is a <a>shorthand</a>
for the 'max-lines', 'block-ellipsis', and 'continue' properties.
Issue: For the time being,
experimental implementations are encouraged
to follow the full behavior defined by this shorthand and its longhands,
but to only expose the shorthand to authors.
This is in order to facilitate further tweaking,
and in particular potential renaming,
of the longhand properties and their values.
It allows limiting the contents of a block container
to the specified number of lines;
remaining content is fragmented away
and neither rendered nor measured.
Optionally, it also allows inserting content into the last line box
to indicate the continuity of truncated/interrupted content.
The values have the following meaning:
<dl dfn-for=line-clamp dfn-type=value>
<dt><dfn>none</dfn>
<dd>Sets 'max-lines' to ''max-lines/none'',
'continue' to ''continue/auto'',
and 'block-ellipsis' to ''block-ellipsis/none''.
<dt><dfn><<integer [1,∞]>></dfn>
<dt><dfn><'block-ellipsis'></dfn>
<dd>
Sets 'continue' to ''discard''
if either or both values ares specified.
Sets 'max-lines' to the specified <<integer>>
or to ''max-lines/none'' if omitted,
and 'block-ellipsis' to other component of the value if specified
or to ''block-ellipsis/auto'' if omitted.
</dl>
See the corresponding longhand properties for details
about how this mechanism operates.
<div class="example">
In this example, the lead paragraph of each article
is listed in a shortened menu,
truncated to fit within 5 lines
that end with “… (continued on next page)”:
<xmp highlight=css>
li {
line-clamp: 5 "… (continued on next page)";
}
strong {
display: block;
text-transform: uppercase;
}
</xmp>
<xmp highlight=markup>
<li><a href="cheese-is-milk">
<strong>Cheese is Actually Made of Milk!</strong>
Investigative reporters at the World Wide Web Press Corps
have discovered the secret of cheese.
Tracing through byzantine layers of bureaucracy and shadow corporations,
our crack team of journalists have traced the source of camembert.
</a></li>
</xmp>
Sample rendering:
<pre class="figure">
+---------------------------------------+
| CHEESE IS ACTUALLY MADE OF MILK! |
| Investigative reporters at the World |
| Wide Web Press Corps have discovered |
| the secret of cheese. Tracing through |
| byzantine… (continued on next page) |
+---------------------------------------+
</pre>
</div>
<h4 id=webkit-line-clamp>
Legacy compatibility</h4>
For compatibility with legacy content,
UAs that support 'line-clamp' must also support the '-webkit-line-clamp' property
and the additional ''-webkit-discard'' value for the 'continue' property.
<pre class="propdef shorthand">
Name: -webkit-line-clamp
Value: none | <<integer [1,∞]>>
Initial: none
Percentages: N/A
</pre>
<pre class="propdef partial">
Name: continue
New Values: -webkit-discard
</pre>
Like 'line-clamp', '-webkit-line-clamp' is a shorthand of 'max-lines', 'continue', and 'block-ellipsis',
except that:
* its syntax is ''line-clamp/none'' | <<integer [1,∞]>>
* it sets 'continue' to ''-webkit-discard'' instead of ''discard''
* it unconditionally sets 'block-ellipsis' to ''block-ellipsis/auto''
The <dfn value for=continue>-webkit-discard</dfn> value behaves identically to ''discard'',
except that it only takes effect
if the [=specified value=] of the 'display' property
is ''-webkit-box'' or ''-webkit-inline-box''
and the value of the '-webkit-box-orient' property
is ''-webkit-box-orient/vertical''.
Note: Implementations of the legacy '-webkit-line-clamp' property
have not behaved identically to what is specified here.
The historical behavior is quirky and less robust,
as documented for example in <a href="https://medium.com/mofed/css-line-clamp-the-good-the-bad-and-the-straight-up-broken-865413f16e5">this blog post</a>.
The current design learns from the mistakes of that early experiment,
and is intended to be sufficiently compatible with existing content
that implementations can eventually be changed to follow to the specified behavior.
If further adjustments are found to be necessary,
they will be incorporated to this specification.
In the meanwhile, authors should be aware that there may be discrepancies.
<h3 id="max-lines">
Forcing a Break After a Set Number of Lines: the 'max-lines' property</h3>
<pre class=propdef>
Name: max-lines
Value: ''none'' | <<integer [1,∞]>>
Initial: ''none''
Applies to: <a>block containers</a> which are also [=fragmentation containers=] that capture [=region breaks=]
Inherited: no
Percentages: N/A
Computed value: the keyword ''max-lines/none'' or an integer
Animation type: by computed value type
</pre>
This property only has an effect on boxes that are [=fragmentation containers=] that capture [=region breaks=].
Also, if the value of 'max-lines' is not <dfn for=max-lines dfn-type=value>none</dfn>,
a <a>region break</a>
is forced after its <var>N</var>th
descendant <a>in-flow</a> <a>line box</a>,
where <var>N</var> is the specified value of 'max-lines'.
Only lines boxes in the same <a>Block Formatting Context</a>
are counted:
the contents of descendants that establish <a>independent formatting contexts</a>
are skipped over while counting line boxes.
If fewer than <var>N</var> line boxes exist,
then 'max-lines' introduces no <a>region break</a>.
Note: This implies that 'max-lines' has no effect when applied to [=multi-column containers=],
since any line box they contain are nested into [=independent formatting contexts=].
Only positive integers are accepted.
Zero or negative integers are invalid
and must cause the declaration to be <a>ignored</a>.
Note: The 'widows', 'orphans', and 'break-inside' properties
do not affect the position of the forced <a>region break</a>
introduced by the 'max-lines' property.
<div class=note>
Note: Despite the “region break” name, this is not a dependency on [[CSS-REGIONS-1]].
The word “region” is only used as a classifier for forced breaks:
they can be “page breaks” (breaks across pages [[css-page-3]]),
“column breaks” (breaks across multi-column layout columns [[css-multicol-1]]),
or “region breaks” (breaks across any other kind of CSS-induced <a>fragmentation containers</a>).
If an implementation supports neither [[CSS-REGIONS-1]] nor [[CSS-OVERFLOW-4#fragmentation]],
then it will have had no occasion yet to run into that kind of breaks,
and this will be an addition.
However the addition does not involve bringing over any of the [[CSS-REGIONS-1]] functionality.
All that is needed is:
* be able to fragment
* classify these fragmentation containers as “Category 3”
(i.e. not pages nor columns)
for the purpose of forced breaks.
</div>