forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverview.bs
1441 lines (1197 loc) · 54.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
<h1>CSS Basic User Interface Module Level 4</h1>
<pre class='metadata'>
ED: https://drafts.csswg.org/css-ui-4/
Status Text: This specification will include and extend <cite>CSS Basic User Interface Module Level 3.</cite> [[CSS3-UI]]
TR: https://www.w3.org/TR/css-ui-4/
Previous Version: https://www.w3.org/TR/2015/WD-css-ui-4-20150922/
Shortname: css-ui
Level: 4
Group: csswg
!Issue Tracking: https://wiki.csswg.org/spec/css4-ui#css4-ui-issues-list
Status: ED
Work Status: Exploring
Editor: Florian Rivoal, On behalf of Bloomberg, http://florian.rivoal.net/
Ignored Terms: box-sizing, resize, text-overflow, caret-color, nav-up, nav-down, nav-left, nav-right
Link Defaults: css-position-3 (property) position
Link Defaults: css21 (property) float
Link Defaults: css21 (property) clear
Link Defaults: selectors-4 (selector) :checked
Link Defaults: selectors-4 (selector) :enabled
Link Defaults: selectors-4 (selector) :disabled
Abstract: This specification describes user interface related
properties and values to style HTML and XML (including XHTML).
It includes and extends user interface related features
from the properties and values of previous CSS levels.
It uses various properties and values
to style basic user interface elements in a document.
At risk: Applicability of 'user-select' to ''::before'' and ''::after''
</pre>
<pre class=link-defaults>
spec:css-writing-modes-4; type:dfn; text:start
spec:css-writing-modes-4; type:dfn; text:end
</pre>
<h2 id="intro">Introduction</h2>
This module describes CSS properties which enable authors
to style user interface related properties and values.
<a href="https://www.w3.org/TR/REC-CSS1#anchor-pseudo-classes">Section 2.1 of CSS1</a> [[CSS1]]
and <a href="https://www.w3.org/TR/CSS2/ui.html">Chapter 18 of CSS2</a> [[CSS21]]
introduced several user interface related properties and values.
<a href="https://www.w3.org/TR/2000/WD-css3-userint-20000216">User Interface for CSS3 (16 February 2000)</a> introduced several new user interface related features.
[[CSS3-UI]] was later introduced to incorporates, extends, and supersedes these.
This specification continues this work, and in turn replaces [[CSS3-UI]].
Note: At the time of writing, [[CSS3-UI]] is not completely finalized yet.
To avoid accidental divergences and maintenance overhead,
This specification is written as a delta specification over CSS-UI Level 3.
Once the level 3 specification is final,
its content will be integrated into this specification,
which will then replace it.
Until then, CSS-UI Level 4 only contains additions and extensions to level 3.
<h3 id="purpose">Purpose</h3>
The purpose of this specification is to achieve the following objectives:
<ul>
<li>Extend the user interface features in CSS2.1 and [[CSS3-UI]]
<li>Provide additional CSS mechanisms to augment or replace other
dynamic presentation related features in HTML.
<li>Introduce directional navigation properties to assist in the construction of
user interfaces which make use of a directional navigation model.
</ul>
<h2 id="interaction">Module Interactions</h2>
This document defines new features not present in earlier specifications.
In addition, it replaces and supersedes [[!CSS3-UI]],
which itself replaced and superseded the following:
<ul>
<li><a href="https://www.w3.org/TR/CSS21/ui.html#cursor-props">Section 18.1</a>,
<a href="https://www.w3.org/TR/CSS21/ui.html#dynamic-outlines">section 18.4</a>,
and Information on the stacking of outlines defined in
<a href="https://www.w3.org/TR/CSS21/zindex.html">Appendix E</a>
of Cascading Style Sheets, level 2, revision 1 [[CSS21]]
<li><a href="https://www.w3.org/TR/2000/WD-css3-userint-20000216">User Interface for CSS3 (16 February 2000)</a> [[CSSUI]]
</ul>
<h2 id="box-model">Box Model addition</h2>
<h3 id="box-sizing">Changing the Box Model: the 'box-sizing' property</h3>
Issue: Add final level 3 content
<h2 id="outline-props">Outline properties</h2>
Issue: Add final level 3 content
<h3 id="outline">Outlines Shorthand: the 'outline' property</h3>
Issue: Add final level 3 content
<h3 id="outline-width">Outline Thickness: the 'outline-width' property</h3>
Issue: Add final level 3 content
<h3 id="outline-style">Outline Patterns: the 'outline-style' property</h3>
Issue: Add final level 3 content
<h3 id="outline-color">Outline Colors: the 'outline-color' property</h3>
Issue: Add final level 3 content
<h3 id="outline-offset">Offsetting the Outline: the 'outline-offset' property</h3>
Issue: Add final level 3 content
<h2 id="resizing-and-overflow">Resizing & Overflow</h2>
Issue: Add final level 3 content
<h3 id="resize">Resizing Boxes: the 'resize' property</h3>
Issue: Add final level 3 content
In addition to elements
whose computed 'overflow' value
is something other than ''visible'',
the 'resize' property also applies
regardless of the value of the ''overflow'' property,
to:
<ul>
<li>Replaced elements representing images or videos, such as <{img}>, <{video}>, <{picture}>, <{svg}>, <{object}>, or <{canvas}>.
<li>The <{iframe}> element.
</ul>
<h3 id="text-overflow"> 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
Media: visual
Computed value: As specified, with <<length>> converted to absolute units
</pre>
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 ''visible''.
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></dt>
<dd>Clip inline content that overflows its block container element.
Characters may be only partially rendered.
</dd>
<dt><dfn id=overflow-ellipsis>ellipsis</dfn></dt>
<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.
</dd>
<dt id=overflow-string><<string>></dt>
<dd>
Render the given string to represent clipped inline content.
The given string is treated as an independent paragraph
for bidi purposes.
</dd>
<dt dfn-type=function><dfn>fade( <<length>> | <<percentage>> )</dfn></dt>
<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?
</dd>
<dt><dfn>fade</dfn></dt>
<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.
</dd>
</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/CSS21/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/CSS21/visuren.html#inline-boxes">
atomic inline-level element</a>
on a line
must be clipped rather than ellipsed.
<h4 id="ellipsing-details" class="no-num no-toc">ellipsing details</h4>
<ul>
<li>
Ellipsing only affects rendering and must not affect layout
nor dispatching of pointer events.
<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>
<h4 id="ellipsis-interaction" class="no-num no-toc">user interaction with ellipsis</h4>
<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"><p style="display:none">Example(s):
<h4 id="text-overflow-examples" class="no-num no-toc">text-overflow examples</h4>
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; padding:.2em; border:solid .1em black; margin:1em 0;
}</code></pre>
sample HTML fragments, renderings, and your browser:
<table style="color:#000;background:#fff" id="awesome-table"><tbody>
<tr><th>HTML</th><th>sample rendering</th><th>your browser</th></tr>
<tr>
<td><pre><code class="lang-markup"><div>
CSS IS AWESOME, YES
</div>
</code></pre></td>
<td>
<object type="image/png" data="images/cssisawesome.png">
First, a box with text drawing outside of it.
</object>
</td>
<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>
</td>
</tr>
<tr>
<td><pre><code class="lang-markup"><div style="<strong>text-overflow:clip;</strong> overflow:hidden">
CSS IS AWESOME, YES
</div>
</code></pre></td>
<td>
<object type="image/png" data="images/cssisaweso.png">
Second, a similar box with the text clipped outside the box.
</object></td>
<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>
</td>
</tr>
<tr>
<td><pre><code class="lang-markup"><div style="<strong>text-overflow:ellipsis;</strong> overflow:hidden">
CSS IS AWESOME, YES
</div>
</code></pre></td>
<td>
<object type="image/png" data="images/cssisaw.png">
Third, a similar box with an ellipsis representing the clipped text.
</object>
</td>
<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>
</td>
</tr>
<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>
<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>
<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>
</td>
</tr>
<tr>
<td><pre><code class="lang-markup"><div style="<strong>text-overflow:fade;</strong> overflow:hidden">
CSS IS AWESOME, YES
</div>
</code></pre></td>
<td>
<object type="image/png" data="images/cssisfade.png">
a box with the text fading out on overflow.
</object></td>
<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>
</td>
</tr>
</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.
<!-- insert RTL example diagram here to illustrate note. -->
<h4 id="ellipsis-scrolling" class="no-num no-toc">ellipsis interaction with scrolling interfaces</h4>
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"><p style="display:none">Example(s):
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> <!-- example -->
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"><p style="display:none">Example(s):
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><!-- example -->
If there is insufficient space for both start
and end ellipses/strings,
then only the end ellipsis/string should be rendered.
Issue: Add final level 3 content
<dl dfn-type=value dfn-for=text-overflow>
</dl>
<h2 id="pointing-keyboard">Pointing Devices and Keyboards</h2>
<h3 id="pointer-interaction">Pointer interaction</h3>
<h4 id="cursor">Styling the Cursor: the 'cursor' property</h4>
Issue: Add final level 3 content
Issue: Amend the definition of ''cursor/auto''
to show ''cursor/default'' rather than ''cursor/text''
over text when 'user-select' is ''user-select/none''.
<h3 id="insertion-caret">Insertion caret</h3>
<h4 id="caret-color">Coloring the Insertion Caret: the 'caret-color' property</h4>
Issue: Add final level 3 content
Issue: Amend the definition of ''caret-color/auto'' to highlight
the fact that when 'caret-shape' is ''caret-shape/block'',
ensuring good visibility and contrast means not using
currentColor.
<!--
<h4 id="caret-animation">Animation of the insertion caret: 'caret-animation'</h4>
<pre class='propdef'>
Name: caret-animation
Value: auto | blink | none | fade
Initial: auto
Applies to: elements that accept input
Inherited: yes
Percentages: N/A
Media: interactive
Computed value: Same as specified value.
Animatable: no
</pre>
On most platforms and in most UAs,
the text insertion caret blinks.
This property allows the author
to control the speed at which it blinks,
or to turn off blinking entirely.
<dl dfn-type=value dfn-for=caret-animation>
<dt><dfn>auto</dfn>
<dd>The UA determines how the caret should be animated, if at all.
It should match platform conventions,
and may be adjusted based on context.
Note: This is typically rendered as a blinking caret.
<dt><dfn>blink</dfn>
<dd>The UA must display a blinking caret.
For accessibility reasons, and based on user preferences,
The UA may display a non animated caret instead.
<dt><dfn>none</dfn>
<dd>The UA must not animate the caret.
Note: This is only about UA driven animations of the caret.
If CSS animations are used to animate the caret color,
these should still apply normally.
<dt><dfn>fade</dfn>
<dd>The UA must display a caret repeatedly fading in and out,
similarly to ''caret-animation/blink'' except it appears and
disappears progressively rather than suddenly.
For accessibility reasons, and based on user preferences,
The UA may display a non animated caret instead.
</dl>
Issue: Do we need the accessibility escape hatch on blink and fade?
Would it be enough instead to expect the UI to put
<code>caret-animation:fixed !important</code> in the
user stylesheet when it wants to prevent the caret
from blinking?
The UA determines the speed at which the cursor blinks or fades.
It should follow platform conventions and settings.
Note: It is recommended to stop the caret from blinking or fading
using ''caret-animation: none''
when applying custom animations using [[CSS3-ANIMATIONS]],
to prevent the blinking or fading and the css animation to interfere.
Note: See <a href="https://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3: Seizures: Do not design content in a way that is known to cause seizures</a> [[WCAG20]].
<div class=example>
A user who is disturbed by or has adverse reactions to blinking or flashing visuals
may want to make all carets static and non-blinking,
regardless of platform defaults or author settings.
This can be accomplished by with the folliwing rule in the user stylesheet.
<pre><code class="lang-css">
/* prevent the caret from blinking/flashing */
:read-write { caret-animation: none !important; }
/* prevent changes of caret-color, including animations */
:read-write { caret-color:auto !important; }
</code></pre>
</div>
UAs that do not have an editable user stylesheet
should provide a setting to disable
<a href="https://www.w3.org/TR/WCAG20/#blinksdef">blinking</a>,
<a href="https://www.w3.org/TR/WCAG20/#flash-def">flashing</a>
and animated carets.
UAs that do have an editable user stylesheet may want to provide this setting as well.
See [[WCAG]] <a href="https://www.w3.org/TR/WCAG20/#time-limits-pause">Guideline 2.2</a>
and <a href="https://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3</a>
for details.
<div class=example>
Normally, the caret blinks between on and off.
This makes it alternate between 2 colors.
<pre><code class="lang-css">
textarea {
caret-animation: none;
caret-color: blue;
animation: caret-alternate 2s step-end infinite;
}
@keyframes caret-alternate {
50% { caret-color: red; }
}
</code></pre>
The simulated rendering below illustrates how this should look.
<style>
@-webkit-keyframes caret-alternate-ref { 50% { border-color: red; } }
@keyframes caret-alternate-ref { 50% { border-color: red; } }
</style>
<div style="border:inset; background: white; width: 10em;">
Text area
with color-alternating caret<span style="border-right: 2px solid blue; animation: caret-alternate-ref 2s step-end infinite;-webkit-animation: caret-alternate-ref 2s step-end infinite;"></span>
</div>
Focus the element below to see how your browser renders it.
<style>
@keyframes caret-alternate-test {
50% { caret-color: red; }
}
</style>
<div contentEditable=true
style="border:inset; background: white; width: 10em;
caret-animation: none;
caret-color: blue;
animation: caret-alternate-test 2s step-end infinite;"
>Text area with color-alternating caret</div>
</div>
-->
<h4 id="caret-shape">Shape of the insertion caret: 'caret-shape'</h4>
<pre class='propdef'>
Name: caret-shape
Value: auto | bar | block | underscore
Initial: auto
Applies to: elements that accept input
Inherited: yes
Percentages: N/A
Media: interactive
Computed value: Same as specified value
Animatable: no
</pre>
This property allows authors to specify
the desired shape of the text insertion caret.
Within the context of this definition, <dfn>character</dfn> is
to be understood as <em>extended grapheme cluster</em>,
as defined in [[!UAX29]], and <dfn>visible character</dfn>
means a character with a non-zero advance measure.
<dl dfn-type=value dfn-for=caret-shape>
<dt><dfn>auto</dfn>
<dd>The UA determines the shape of the caret.
It should match platform conventions,
and may be adjusted based on context.
For example, if a UA switches between insert mode and overtype mode when the
user presses the <em>insert</em> key on their keyboard,
it may show a ''caret-shape/bar'' caret in insert mode,
and a ''caret-shape/block'' caret in overtype mode.
<dt><dfn>bar</dfn>
<dd>The UA must render the text insertion caret
as a thin bar placed at the insertion point.
This means it is between, before, or after characters, not over them.
It should be perpendicular to the inline progression direction,
although UAs may render it slanted when inserting italic or oblique text.
<dt><dfn>block</dfn>
<dd>The UA must render the text insertion caret
as a rectangle overlapping the next visible character following the insertion point.
If there is no visible character after the insertion point,
the UA must render the caret after the last visible character.
UAs may render it as a slanted rectangle when inserting italic or oblique text.
<dt><dfn>underscore</dfn>
<dd>The UA must render the text insertion caret
as a thin line <a>under</a> (as defined in [[!CSS-WRITING-MODES-3]]
the next visible character following the insertion point.
If there is no visible character after the insertion point,
the UA must render the caret after the last visible character.
</dl>
The width of the ''caret-shape/block'' and ''caret-shape/underscore'' carets
should be the advance measure of the next visible character after the insertion point,
or ''1ch'' if there is no next visible character
or if this information is impractical to determine.
When determining the orientation and appearance of the caret,
UAs must take into account the <a>writing mode</a> [[!CSS-WRITING-MODES-3]]
and must apply transformations [[!CSS-TRANSFORMS-1]].
If the edited text is laid out out on a path,
for instance by using the SVG <{textPath}> element,
UAs should also account for this.
The stacking position of the caret is left undefined, within the following constraints:
<ul>
<li>The caret must not be obscured by the background of the element
<li>UAs must render ''caret-shape/block'' carets so that the
character it overlaps with is not obscured by the caret
</ul>
<div class=example>
This illustrates the typical appearance of the various caret shapes.
In each of the sample renderings below,
the insertion point is between the letters u and m.
<style>
@-webkit-keyframes caret-bar-ref { 50% { outline-color: transparent; } }
@-webkit-keyframes caret-block-ref { 50% { background: transparent; } }
@-webkit-keyframes caret-underscore-ref { 50% { border-color: transparent; } }
@keyframes caret-bar-ref { 50% { outline-color: transparent; } }
@keyframes caret-block-ref { 50% { background: transparent; } }
@keyframes caret-underscore-ref { 50% { border-color: transparent; } }
#caret-shape-example {
min-width: 25em;
}
#caret-shape-example,
#caret-shape-example td,
#caret-shape-example th {
border: solid 1px;
}
#caret-shape-example td+td {
background:white;
}
</style>
<table id="caret-shape-example">
<tr><th>'caret-shape'<th>Sample rendering<th>Your browser<br>(focus each cell to see the caret)
<tr><td>''bar''<td>Lorem ipsu<span style="outline: 1px solid black;animation: caret-bar-ref 2s step-end infinite;-webkit-animation: caret-bar-ref 2s step-end infinite;">​</span>m<td style contentEditable=true style="caret-shape: bar">Lorem Ipsum
<tr><td>''caret-shape/block''<td>Lorem ipsu<span style="background: #bbb; -webkit-animation: caret-block-ref 2s step-end infinite;animation: caret-block-ref 2s step-end infinite;">m</span><td contentEditable=true style="caret-shape: block">Lorem Ipsum
<tr><td>''underscore''<td>Lorem ispu<span style="border-bottom: 2px solid black; -webkit-animation: caret-underscore-ref 2s step-end infinite; animation: caret-underscore-ref 2s step-end infinite;">m</span><td contentEditable=true style="caret-shape: underscore">Lorem Ipsum
</table>
</div>
<div class=example>
''caret-shape/underscore'' or ''caret-shape/block'' carets are commonly used
in terminals and command lines,
as in this example.
<pre><code class="lang-css">
.console {
caret-shape: underscore;
background: black;
color: white;
font-family: monospace;
padding: 1ex;
}
</code></pre>
The simulated rendering below illustrates how this should look.
<style>
@-webkit-keyframes terminal-caret-ref { 50% { border-color: transparent; } }
@keyframes terminal-caret-ref { 50% { border-color: transparent; } }
</style>
<pre style="background: black; color: white; font-family: monospace; padding: 1ex">
user@host:css-ui-4 $ ls -a
. .. Overview.bs Overview.html
user@host:css-ui-4 $ <span style="border-bottom: 2px solid white;animation: terminal-caret-ref 2s step-end infinite;-webkit-animation: terminal-caret-ref 2s step-end infinite;"> </span>
</pre>
Focus the element below to see how your browser renders it.
<pre contentEditable=true style="background: black; color: white; font-family: monospace; padding: 1ex; caret-shape: underscore;">
user@host:css-ui-4 $ ls -a
. .. Overview.bs Overview.html
user@host:css-ui-4 $
</pre>
</div>
<h4 id="caret">Insertion caret shorthand: 'caret'</h4>
<!-- Value: <<'caret-color'>> || <<'caret-animation'>> || <<'caret-shape'>> -->
<pre class='propdef'>
Name: caret
Value: <<'caret-color'>> || <<'caret-shape'>>
Initial: auto
Applies to: elements that accept input
Inherited: yes
Percentages: N/A
Media: interactive
Computed value: See individual properties
Animatable: See individual properties
</pre>
This property is a shorthand for setting
'caret-color' <!--, 'caret-animation'--> and 'caret-shape' in one declaration.
Omitted values are set to their initial values.
<!--
<div class=example>
This example illustrates using the various caret related properties
in combination.
They are used here to simulate the appearance of the caret
on an old phosphor computer monitor.
<pre><code class="lang-css">
#old-screen {
caret: block none;
animation: old-caret 2s infinite;
/*styling of the screen omitted for brevity */
}
@keyframes old-caret {
from, 50% { caret-color: green; }
75%, to { caret-color: transparent; }
}
</code></pre>
The simulated rendering below illustrates how this should look.
<style>
.old-screen {
border-radius: 1em;
padding: 1em;
color: green;
font-family: monospace;
white-space: pre;
background: repeating-linear-gradient(#030 0px, #030 1px, #020 1px, #020 3px);
}
.old-screen span {
display:inline-block;
white-space: pre;
caret: block 0s;
animation: caret-old-ref 2s infinite;
-webkit-animation: caret-old-ref 2s infinite;
}
@keyframes caret-old-ref {
from, 50% { background-color: green; }
75%, to { background-color: transparent; }
}
@-webkit-keyframes caret-old-ref {
from, 50% { background-color: green; }
75%, to { background-color: transparent; }
}
</style>
<div class="old-screen" style="height: 100px">> <span> </span></div>
Focus the element below to see how your browser renders it.
<div class="old-screen" contentEditable="true" style="height: 100px">> </div>
</div>
-->
<h3 id="keyboard">Keyboard control</h3>
<h4 id="nav-dir">Directional Focus Navigation: the 'nav-up', 'nav-right', 'nav-down', 'nav-left' properties</h4>
Issue: Add final level 3 content
<h4 id="input-method-editor">Obsolete: the ime-mode property</h4>
Issue: Add final level 3 content
<h2 id="user-interaction">User Interaction</h2>
<h3 id="content-selection">Controlling content selection</h3>
The 'user-select' property enables authors to specify
which elements in the document can be selected by the user and how.
This allows for easier interactions when not
all elements are equally useful to select,
avoiding accidental selections of neighbouring content.
<pre class='propdef'>
Name: user-select
Value: auto | text | none | contain | all
Initial: auto
Inherited: no
Applies to: all elements, and optionally to the ''::before'' and ''::after'' pseudo elements
Media: interactive
Computed value: See below
</pre>
User Agents must not apply the 'user-select' property to
the ''::first-line'' and ''::first-letter'' pseudo elements.
Note: The UA may apply this property to the ''::before'' and ''::after'' pseudo elements.
If it does, ''user-select/auto'' value computes to ''user-select/none'' on these pseudos,
but other values can be specified.
This preserves the legacy behavior of generated content not being selectable or copyable,
which is appropriate when these pseudos are used for decorative purposes.
However, this property allows them to become selectable and copyable,
as the user would expect in cases where they are used to generate part of the content,
such as the issue numbers in this document.
<strong class="advisement">To the extent possible,
authors should avoid using generated content
for non decorative purposes,
and should prefer including all the content in the DOM.</strong>
<em>This feature is at risk.</em>
Issue: if we allow user-select to change to a value other than ''user-select/none'',
we need to figure out what this means for copyability, and DOM APIs.
When generated content in pseudo elements becomes selectable
through this mechanism,
UAs should also make this content findable through their search function.
Issue: Should it also apply to ''::marker''? To <a>page-margin boxes</a>?
Should the computed value of '''user-select/auto'' also be ''user-select/none'',
or would ''user-select/text'' be more appropriate?
The computed value is the specified value,
except:
<ol>
<li>on <a>editable element</a>s
where the computed value is always ''user-select/contain''
regardless of the specified value
<li>when the specified value is ''user-select/auto'',
which computes one of the other values as defined below
</ol>
For the purpose of this specification,
an <dfn>editable element</dfn> is either
an <a href="https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#editing-host">editing host</a>
or a <a href="https://www.w3.org/TR/html/forms.html#mutability">mutable</a> form control with textual content,
such as <{textarea}>.
Issue: Should there be constraints
on what happens to the computed value
on elements that are editable descendants of editing hosts?
The semantics are not obvious.
Maybe ''user-select/none'' should compute to ''text'',
or maybe all values should compute to ''text''.
<dl dfn-type=value dfn-for=user-select>
<dt><dfn>auto</dfn>
<dd>The computed value of ''user-select/auto'' is determined as follows:
<ul>
<li>On the ''::before'' and ''::after'' pseudo elements,
the computed value is ''user-select/none''
<li>If the element is an <a>editable element</a>,
the computed value is ''user-select/contain''
<li>Otherwise,
if the computed value of 'user-select' on the parent of this element is ''all'',
the computed value is ''all''
<li>Otherwise,
if the computed value of 'user-select' on the parent of this element is ''user-select/none'',
the computed value is ''user-select/none''
<li>Otherwise, the computed value is ''text''
</ul>
Note: This unusual combination of a non inherited property with an initial value of ''user-select/auto''
whose computed value depends on the parent element
makes it possible to create what is effectively selective inheritance.
This was initially proposed by Microsoft in IE to introduce a behavior similar to inheritance
except that the ''user-select/contain'' value does not inherit.
<dt><dfn>text</dfn>
<dd>The element imposes no constraint on the selection.
<dt><dfn>none</dfn>
<dd>
The UA must not allow selections to be started in this element.
A selection started outside of this element must not end in this element.
If the user attempts to create such a selection,
the UA must instead end the selection range at the element boundary.
Note: As of the time of writing, experimental implementations do not all behave like this.
Firefox does.
Chrome and Safari almost do: for a selection started after the element
and trying to go backwards into the element
they behave as specified here,
but for a selection started before the element
and trying to go into the element
they behave as if the element has ''all'' and select it entirely.
IE does not restrict selections started outside of the element
from going into it at all.
Another difference is that in Chrome and Safari,
if the user attempts to start a selection inside a ''user-select: none'',
and to end the selection out of it,
a selection will be created from the boundary of the element
to the user-designated end-point.
Firefox and Internet explorer behave as prescribed in this specification
and do not create a selection at all.
However, if this element has descendants on which the computed value of 'user-select' is not ''user-select/none'',
selections that start and end within these descendants are allowed.
The UA must allow selections to extend across this element,
and must exclude this element from such a selection.
An exception is made for UAs which do not support multiple ranges per selection,
and they may include this element.
If the element has descendants on which 'user-select' does not compute to ''user-select/none'',
these descendants must be included in a selection extending across the element.
<span class=note>This specification makes no normative requirement
about the behavior of the clipboard.
however, UAs are encouraged to keep the visual selection consistent
with what would get copied to the clipboard when copying.