Skip to content

Commit 03aa791

Browse files
frivoaljeremyromanemilioLoirooriol
authored
[css-ui-4] Clarify the applicability of the caret-* properties (#11373)
Co-authored-by: Jeremy Roman <[email protected]> Co-authored-by: Emilio Cobos Álvarez <[email protected]> Co-authored-by: Oriol Brufau <[email protected]>
1 parent aa2e02d commit 03aa791

File tree

1 file changed

+70
-51
lines changed

1 file changed

+70
-51
lines changed

css-ui-4/Overview.bs

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,26 +1082,57 @@ Cursor of the canvas</h5>
10821082
<h3 id="insertion-caret">
10831083
Insertion caret</h3>
10841084

1085+
The <dfn lt="insertion caret|caret">insertion caret</dfn> (or “caret” for short)
1086+
is a visible indicator of the insertion point in an element that [=accepts text input=],
1087+
where text (and potentially other content) can be inserted by the user.
1088+
The 'caret-color', 'caret-animation', and 'caret-shape' properties
1089+
give the author some amount of control over the appearance of the [=caret=].
1090+
1091+
Text or elements are considered to <dfn>accept text input</dfn>
1092+
if they are either an [=editable element=] or a descendent thereof,
1093+
excluding any such element where the [=used value=] of 'user-select' is ''user-select/none'',
1094+
as well as subtrees rooted at an HTML element with a {{ElementContentEditable/contentEditable}} attribute set to {{ElementContentEditable/contentEditable/false}}.
1095+
1096+
Some user agents have other user interface mechanisms
1097+
with a similar appearance,
1098+
also occasionally referred to as “carets”.
1099+
For example, some UAs can show a “navigation caret”,
1100+
which acts similarly to an [=insertion caret=]
1101+
but can be moved around in non-editable text.
1102+
The 'caret-color', 'caret-animation', and 'caret-shape' properties
1103+
are not intended to apply to such mechanisms
1104+
nor outside of [=editable elements=],
1105+
though user agents may choose to take them into account.
1106+
Whether to do so and to what extent is up to the user agent.
1107+
1108+
Note: The cursor image shown
1109+
when hovering over text when the 'cursor' property is ''cursor/auto'',
1110+
or when hovering over an element where the 'cursor' property is ''cursor/text'' or ''cursor/vertical-text'',
1111+
though it sometimes resembles a caret,
1112+
is not a caret (it's a cursor).
1113+
10851114
<h4 id="caret-color" caniuse="css-caret-color">
10861115
Coloring the Insertion Caret: the 'caret-color' property</h4>
10871116

10881117
<pre class="propdef">
10891118
Name: caret-color
10901119
Value: auto | <<color>>
10911120
Initial: auto
1092-
Applies to: all elements
1121+
Applies to: text or elements that [=accept text input=]
10931122
Inherited: yes
10941123
Percentages: N/A
10951124
Computed value: The computed value for ''caret-color/auto'' is ''caret-color/auto''.
10961125
For <<color>> values, see [[CSS-COLOR-4#resolving-color-values]].
10971126
Animation Type: by computed value
10981127
</pre>
10991128

1129+
This property controls the color of the [=insertion caret=].
1130+
11001131
<dl>
11011132
<dt>auto
11021133
<dd>
11031134
User agents should use ''currentColor''.
1104-
User agents may automatically adjust the color of caret
1135+
User agents may automatically adjust the color of [=caret=]
11051136
to ensure good visibility and contrast with the surrounding content,
11061137
possibly based on the currentColor, background, shadows, etc.
11071138

@@ -1111,21 +1142,9 @@ Coloring the Insertion Caret: the 'caret-color' property</h4>
11111142

11121143
<dt><<color>>
11131144
<dd>
1114-
The insertion caret is colored with the specified color.
1145+
The [=caret=] is colored with the specified color.
11151146
</dl>
11161147

1117-
The caret is a visible indicator of the insertion point in an element where text (and potentially other content) is inserted by the user. This property controls the color of that visible indicator.
1118-
1119-
Note: UAs might have additional things that count as “carets”.
1120-
For example, some UAs can show a “navigation caret”,
1121-
which acts similarly to an insertion caret
1122-
but can be moved around in non-editable text
1123-
and is functionally a caret.
1124-
On the other hand, the cursor image shown
1125-
when hovering over text when the 'cursor' property is ''cursor/auto'',
1126-
or when hovering over an element where the 'cursor' property is ''cursor/text'' or ''cursor/vertical-text'',
1127-
though it sometimes resembles a caret, is not a caret (it's a cursor).
1128-
11291148
<div class="example">
11301149
Example: a textarea with
11311150
<code class="lang-css">caret-color:#00aacc;</code>
@@ -1143,39 +1162,39 @@ Animation of the insertion caret: 'caret-animation'</h4>
11431162
Name: caret-animation
11441163
Value: auto | manual
11451164
Initial: auto
1146-
Applies to: elements that accept input
1165+
Applies to: text or elements that [=accept text input=]
11471166
Inherited: yes
11481167
Percentages: N/A
11491168
Computed value: specified keyword
11501169
Animation type: discrete
11511170
</pre>
11521171

11531172
On most platforms and in most UAs,
1154-
the text insertion caret blinks.
1173+
the [=insertion caret=] blinks.
11551174
This property allows the author
1156-
to take control over the way the caret is animated.
1175+
to take control over the way the [=caret=] is animated.
11571176

11581177
<dl dfn-type=value dfn-for=caret-animation>
11591178
<dt><dfn>auto</dfn>
11601179
<dd>
1161-
The UA determines how the caret should be animated, if at all,
1180+
The UA determines how the [=caret=] should be animated, if at all,
11621181
as well as the speed of any such animation.
11631182
It should match platform conventions and settings,
11641183
and may be adjusted based on context.
11651184

1166-
Note: This is typically rendered as a blinking caret.
1185+
Note: This is typically rendered as a blinking [=caret=].
11671186
Fading in and out instead of blinking is a variant that appears in some environments.
11681187

11691188
<dt><dfn>manual</dfn>
11701189
<dd>
1171-
The UA must not animate the caret.
1190+
The UA must not animate the [=caret=].
11721191

1173-
Note: This is only about UA-driven animations of the caret.
1174-
When CSS animations are used to animate the caret color,
1192+
Note: This is only about UA-driven animations of the [=caret=].
1193+
When CSS animations are used to animate the [=caret=] color,
11751194
they apply normally.
11761195
</dl>
11771196

1178-
Note: It is recommended for authors to stop the caret from blinking or fading
1197+
Note: It is recommended for authors to stop the [=caret=] from blinking or fading
11791198
using ''caret-animation: manual''
11801199
when applying custom animations using [[CSS3-ANIMATIONS]],
11811200
to prevent the UA's animation and the CSS animation to interfere.
@@ -1184,7 +1203,7 @@ Animation of the insertion caret: 'caret-animation'</h4>
11841203

11851204
<div class=example>
11861205
A user who is disturbed by or has adverse reactions to blinking or flashing visuals
1187-
may want to make all carets static and non-blinking,
1206+
may want to make all [=carets=] static and non-blinking,
11881207
regardless of platform defaults or author settings.
11891208
This can be accomplished with the following rule in the user stylesheet.
11901209

@@ -1201,14 +1220,14 @@ Animation of the insertion caret: 'caret-animation'</h4>
12011220
should provide a setting to disable
12021221
<a href="https://www.w3.org/TR/WCAG20/#blinksdef">blinking</a>,
12031222
<a href="https://www.w3.org/TR/WCAG20/#flash-def">flashing</a>,
1204-
and animated carets.
1223+
and animated [=carets=].
12051224
UAs that do have an editable user stylesheet may want to provide this setting as well.
12061225
See [[WCAG]] <a href="https://www.w3.org/TR/WCAG20/#time-limits-pause">Guideline 2.2</a>
12071226
and <a href="https://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3</a>
12081227
for details.
12091228

12101229
<div class=example>
1211-
Typically, the caret blinks on and off.
1230+
Typically, the [=caret=] blinks on and off.
12121231
This makes it alternate between 2 colors.
12131232
<pre><code class="lang-css">
12141233
textarea {
@@ -1245,7 +1264,7 @@ Animation of the insertion caret: 'caret-animation'</h4>
12451264
</div>
12461265

12471266
<div class=advisement>
1248-
If a user agent is unwilling to yield control of caret animations
1267+
If a user agent is unwilling to yield control of [=caret=] animations
12491268
to page authors and would not honor ''caret-animation: manual'',
12501269
it must not implement the property at all.
12511270

@@ -1263,15 +1282,15 @@ Shape of the insertion caret: 'caret-shape'</h4>
12631282
Name: caret-shape
12641283
Value: auto | bar | block | underscore
12651284
Initial: auto
1266-
Applies to: elements that accept input
1285+
Applies to: text or elements that [=accept text input=]
12671286
Inherited: yes
12681287
Percentages: N/A
12691288
Computed value: specified keyword
12701289
Animation type: by computed value
12711290
</pre>
12721291

12731292
This property allows authors to specify
1274-
the desired shape of the text insertion caret.
1293+
the desired shape of the [=insertion caret=].
12751294

12761295
Within the context of this definition, <dfn>character</dfn> is
12771296
to be understood as <em>extended grapheme cluster</em>,
@@ -1281,56 +1300,56 @@ Shape of the insertion caret: 'caret-shape'</h4>
12811300
<dl dfn-type=value dfn-for=caret-shape>
12821301
<dt><dfn>auto</dfn>
12831302
<dd>
1284-
The UA determines the shape of the caret.
1303+
The UA determines the shape of the [=caret=].
12851304
It should match platform conventions,
12861305
and may be adjusted based on context.
12871306
For example, if a UA switches between insert mode and overtype mode when the
12881307
user presses the <em>insert</em> key on their keyboard,
1289-
it may show a ''caret-shape/bar'' caret in insert mode,
1290-
and a ''caret-shape/block'' caret in overtype mode.
1308+
it may show a ''caret-shape/bar'' [=caret=] in insert mode,
1309+
and a ''caret-shape/block'' [=caret=] in overtype mode.
12911310

12921311
<dt><dfn>bar</dfn>
12931312
<dd>
1294-
The UA must render the text insertion caret
1313+
The UA must render the [=insertion caret=]
12951314
as a thin bar placed at the insertion point.
12961315
This means it is between, before, or after <a>characters</a>, not over them.
12971316
It should be perpendicular to the inline progression direction,
12981317
although UAs may render it slanted when inserting italic or oblique text.
12991318

13001319
<dt><dfn>block</dfn>
13011320
<dd>
1302-
The UA must render the text insertion caret
1321+
The UA must render the [=insertion caret=]
13031322
as a rectangle overlapping the next <a>visible character</a> following the insertion point.
13041323
If there is no <a>visible character</a> after the insertion point,
13051324
the UA must render the caret after the last <a>visible character</a>.
13061325
UAs may render it as a slanted rectangle when inserting italic or oblique text.
13071326

13081327
<dt><dfn>underscore</dfn>
13091328
<dd>
1310-
The UA must render the text insertion caret
1329+
The UA must render the [=insertion caret=]
13111330
as a thin line <a>under</a> (as defined in [[!CSS-WRITING-MODES-3]]
13121331
the next <a>visible character</a> following the insertion point.
13131332
If there is no <a>visible character</a> after the insertion point,
13141333
the UA must render the caret after the last <a>visible character</a>.
13151334
</dl>
13161335

1317-
The width of the ''caret-shape/block'' and ''caret-shape/underscore'' carets
1336+
The width of the ''caret-shape/block'' and ''caret-shape/underscore'' [=carets=]
13181337
should be the advance measure of the next <a>visible character</a> after the insertion point,
13191338
or ''1ch'' if there is no next <a>visible character</a>
13201339
or if this information is impractical to determine.
13211340

1322-
When determining the orientation and appearance of the caret,
1341+
When determining the orientation and appearance of the [=caret=],
13231342
UAs must take into account the <a>writing mode</a> [[!CSS-WRITING-MODES-3]]
13241343
and must apply transformations [[!CSS-TRANSFORMS-1]].
13251344
If the edited text is laid out on a path,
13261345
for instance by using the SVG <{textPath}> element,
13271346
UAs should also account for this.
13281347

1329-
The thickness of ''caret-shape/bar'' and ''caret-shape/underscore'' carets--
1330-
as well as that of ''caret-shape/auto'' carets with a similar rendering--
1348+
The thickness of ''caret-shape/bar'' and ''caret-shape/underscore'' [=carets=]--
1349+
as well as that of ''caret-shape/auto'' [=carets=] with a similar rendering--
13311350
is determined by the user agent.
13321351
When practical, the user agent should choose a thickness that ensures
1333-
the caret remains visible even if it has been scaled down
1352+
the [=caret=] remains visible even if it has been scaled down
13341353
via means such as transformations [[CSS-TRANSFORMS-1]].
13351354

13361355
When there is not enough room at the end of a line
@@ -1340,19 +1359,19 @@ Shape of the insertion caret: 'caret-shape'</h4>
13401359
past the bounds of the [=scrollable overflow area=];
13411360
user agents may impose limits on this and clip as necessary.
13421361

1343-
The stacking position of the caret is left undefined within the following constraints:
1362+
The stacking position of the [=caret=] is left undefined within the following constraints:
13441363

13451364
<ul>
13461365
<li>
1347-
The caret must not be obscured by the background of the element.
1366+
The [=caret=] must not be obscured by the background of the element.
13481367

13491368
<li>
1350-
UAs must render ''caret-shape/block'' carets
1351-
so that the character it overlaps with is not obscured by the caret.
1369+
UAs must render ''caret-shape/block'' [=carets=]
1370+
so that the character it overlaps with is not obscured by the [=caret=].
13521371
</ul>
13531372

13541373
<div class=example>
1355-
This illustrates the typical appearance of the various caret shapes.
1374+
This illustrates the typical appearance of the various [=caret=] shapes.
13561375
In each of the sample renderings below,
13571376
the insertion point is between the letters u and m.
13581377

@@ -1376,7 +1395,7 @@ Shape of the insertion caret: 'caret-shape'</h4>
13761395
<tr>
13771396
<th>'caret-shape'
13781397
<th>Sample rendering
1379-
<th>Your browser<br>(focus each cell to see the caret)
1398+
<th>Your browser<br>(focus each cell to see the [=caret=])
13801399

13811400
<tr>
13821401
<td>''bar''
@@ -1396,7 +1415,7 @@ Shape of the insertion caret: 'caret-shape'</h4>
13961415
</div>
13971416

13981417
<div class=example>
1399-
''caret-shape/underscore'' or ''caret-shape/block'' carets are commonly used
1418+
''caret-shape/underscore'' or ''caret-shape/block'' [=carets=] are commonly used
14001419
in terminals and command lines,
14011420
as in this example.
14021421
<pre><code class="lang-css">
@@ -1435,7 +1454,7 @@ Shape of the insertion caret: 'caret-shape'</h4>
14351454
Name: caret
14361455
Value: <<'caret-color'>> || <<'caret-animation'>> || <<'caret-shape'>>
14371456
Initial: auto
1438-
Applies to: elements that accept input
1457+
Applies to: text or elements that [=accept text input=]
14391458
Inherited: yes
14401459
Percentages: N/A
14411460
</pre>
@@ -1445,9 +1464,9 @@ Shape of the insertion caret: 'caret-shape'</h4>
14451464
Omitted values are set to their initial values.
14461465

14471466
<div class=example>
1448-
This example illustrates using the various caret-related properties
1467+
This example illustrates using the various [=caret=]-related properties
14491468
in combination.
1450-
They are used here to simulate the appearance of the caret
1469+
They are used here to simulate the appearance of the [=caret=]
14511470
on an old phosphor computer monitor.
14521471

14531472
<pre><code class="lang-css">

0 commit comments

Comments
 (0)