@@ -165,20 +165,143 @@ textarea {
165165
166166 The simulated rendering below illustrates how this would look.
167167 <style>
168- @keyframes caret-alternate {
169- from { border-color: blue; }
170- 50% { border-color: red; }
171- }
168+ @-webkit-keyframes caret-alternate { from { border-color: blue; } 50% { border-color: red; } }
169+ @keyframes caret-alternate { from { border-color: blue; } 50% { border-color: red; } }
172170 </style>
173171 <div style="border:inset; background: white; width: 10em;">
174172 Text area
175- with color-alternating caret<span style="border-right: 2px solid blue;animation: caret-alternate 2s step-end infinite;"></span>
173+ with color-alternating caret<span style="border-right: 2px solid blue;animation: caret-alternate 2s step-end infinite;-webkit-animation: caret-alternate 2s step-end infinite; "></span>
176174 </div>
177175</div>
178176
179177
178+ <h4 id="caret-shape">Shape of the insertion caret: 'caret-shape'</h4>
179+
180+ <pre class='propdef'>
181+ Name : caret-shape
182+ Value : ''auto'' | ''bar'' | ''block'' | ''underscore''
183+ initial : auto
184+ Applies to : elements that accept input
185+ Inherited : yes
186+ Percentages : N/A
187+ Media : interactive
188+ Computed value : Same as specified value
189+ Animatable : no
190+ </pre>
191+
192+ This property allows authors to specify
193+ the desired shape of the text insertion caret.
194+
195+ Within the context of this definition, <dfn>character</dfn> is
196+ to be understood as <em> extended grapheme cluster</em> ,
197+ as defined in [[!UAX29]] , and <dfn>visible character</dfn>
198+ means a character with a non-zero advance measure.
199+
200+ <dl dfn-type=value dfn-for=caret-shape>
201+ <dt> <dfn>auto</dfn>
202+ <dd> The UA determine the shape of the caret.
203+ It should match platform conventions,
204+ and may be adjusted based on context.
205+ For example, if a UA switches between insert mode and overtype mode when the
206+ user presses the <em> insert</em> key on their keyboard,
207+ it may show a ''caret-shape/bar'' caret in insert mode,
208+ and a ''caret-shape/block'' caret in overtype mode.
209+ <dt> <dfn>bar</dfn>
210+ <dd> The UA must render the text insertion caret
211+ as a thin bar placed at the insertion point.
212+ This means it is between, before, or after characters, not over them.
213+ It should be perpendicular to the inline progression direction,
214+ although UAs may render it slanted when inserting italic or oblique text.
215+ <dt> <dfn>block</dfn>
216+ <dd> The UA must render the text insertion caret
217+ as a rectangle overlapping the next visible character following the insertion point.
218+ If there is no visible character after the insertion point,
219+ the UA must render the caret after the last visible character.
220+ UAs may render it as a slanted rectangle when inserting italic or oblique text.
221+ <dt> <dfn>underscore</dfn>
222+ <dd> The UA must render the text insertion caret
223+ as a thin line <a>under</a> (as defined in [[!CSS-WRITING-MODES-3]]
224+ the next visible character following the insertion point.
225+ If there is no visible character after the insertion point,
226+ the UA must render the caret after the last visible character.
227+ </dl>
228+
229+ The width of the ''caret-shape/block'' and ''caret-shape/underscore'' carets
230+ should be the advance measure of the next visible character after the insertion point,
231+ or ''1ch'' if there is no next visible character
232+ or if this information is impractical to determine.
233+
234+ When determining the orientation and appearance of the caret,
235+ UAs must take into account the <a>writing mode</a> [[!CSS-WRITING-MODES-3]]
236+ and must apply transformations [[!CSS-TRANSFORMS-1]] .
237+ If the edited text is laid out out on a path,
238+ for instance by using the SVG <{textPath}> element,
239+ UAs should also account for this.
180240
241+ The stacking position of the caret is left undefined, within the following constraints:
242+ <ul>
243+ <li> The caret must not be obscured by the background of the element
244+ <li> UAs must render ''caret-shape/block'' carets so that the
245+ character it overlaps with is not obscured by the caret
246+ </ul>
181247
248+ <div class=example>
249+ This illustrates the typical appearance of the various caret shapes.
250+ In each of the sample renderings below,
251+ the insertion point is between the letters u and m.
252+
253+ <style>
254+ @-webkit-keyframes caret-bar { from { outline-color: black; } 50% { outline-color: transparent; } }
255+ @-webkit-keyframes caret-block { from { background: #bbb; } 50% { background: transparent; } }
256+ @-webkit-keyframes caret-underscore { from { border-color: black; } 50% { border-color: transparent; } }
257+ @keyframes caret-bar { from { outline-color: black; } 50% { outline-color: transparent; } }
258+ @keyframes caret-block { from { background: #bbb; } 50% { background: transparent; } }
259+ @keyframes caret-underscore { from { border-color: black; } 50% { border-color: transparent; } }
260+ #caret-shape-example {
261+ min-width: 25em;
262+ }
263+ #caret-shape-example,
264+ #caret-shape-example td,
265+ #caret-shape-example th {
266+ border: solid 1px;
267+ }
268+ #caret-shape-example td+td {
269+ background:white;
270+ }
271+ </style>
272+ <table id="caret-shape-example">
273+ <tr><th> 'caret-shape' <th> Sample rendering
274+ <tr><td> ''bar'' <td> Lorem ipsu<span style="outline: 1px solid;animation: caret-bar 2s step-end infinite;-webkit-animation: caret-bar 2s step-end infinite;"></span> m
275+ <tr><td> ''block'' <td> Lorem ipsu<span style="-webkit-animation: caret-block 2s step-end infinite;animation: caret-block 2s step-end infinite;"> m</span>
276+ <tr><td> ''underscore'' <td> Lorem ispu<span style="border-bottom: 2px solid; -webkit-animation: caret-underscore 2s step-end infinite; animation: caret-underscore 2s step-end infinite;"> m</span>
277+ </table>
278+ </div>
279+
280+
281+ <div class=example>
282+ ''caret-shape/underscore'' or ''caret-shape/block'' carets are commonly used
283+ in terminals and command lines,
284+ as in this example.
285+ <pre><code class="lang-css">
286+ .console {
287+ caret-shape: underscore;
288+ background: black;
289+ color: white;
290+ font-family: monospace;
291+ padding: 1ex;
292+ }
293+ </code></pre>
294+
295+ <style>
296+ @-webkit-keyframes terminal-caret { from { border-color: white; } 50% { border-color: transparent; } }
297+ @keyframes terminal-caret { from { border-color: white; } 50% { border-color: transparent; } }
298+ </style>
299+ <pre style="background: black; color: white; font-family: monospace; padding: 1ex">
300+ user@host:css-ui-4 $ ls -a
301+ . .. Overview.bs Overview.html
302+ user@host:css-ui-4 $ <span style="border-bottom: 2px solid white;animation: terminal-caret 2s step-end infinite;-webkit-animation: terminal-caret 2s step-end infinite;"> </span>
303+ </pre>
304+ </div>
182305<h3 id="keyboard">Keyboard control</h3>
183306
184307<h4 id="nav-dir">Directional focus navigation: the 'nav-up', 'nav-right', 'nav-down', 'nav-left' properties</h4>
0 commit comments