Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The caret-animation CSS property is used to enable or disable the blinking behavior of the insertion caret, the visible marker that appears in editable elements to indicate where the next character will be inserted or deleted.
When applying a custom animation to the caret, you should stop the default blinking so that it doesn't interfere with the animation.
/* Keyword values */ caret-animation: auto; caret-animation: manual; /* Global values */ caret-animation: inherit; caret-animation: initial; caret-animation: revert; caret-animation: revert-layer; caret-animation: unset;
The caret-animation property is specified as one of the keyword values listed below.
caret-animation =
auto |
manual
caret-animation usageThis example shows the difference between having caret-animation set to auto versus manual on an editable element.
The markup features two <p> elements with contenteditable set to make them editable.
<p contenteditable="true"> My caret animates because <code>caret-animation</code> is set to <code>auto</code>. </p> <p contenteditable="true"> My caret doesn't animate because <code>caret-animation</code> is set to <code>manual</code>. </p>
The CSS sets the caret-color value to red. It then gives the first paragraph a caret-animation value of auto and the second paragraph a caret-animation value of manual.
p {
caret-color: red;
}
p:first-of-type {
caret-animation: auto;
}
p:last-of-type {
caret-animation: manual;
}
The rendered result looks like so:
Try focusing the two paragraphs to see the difference in caret behavior.
In this example, a custom caret animation is applied to an editable paragraph and a text input.
The markup features a <p> element and two text <input> elements. The <p> element has the contenteditable attribute set on it to make it editable. The paragraph and first text input have a class of custom-caret set on them.
<p contenteditable="true" class="custom-caret"> This paragraph has a custom animation applied to it, plus <code>caret-animation: manual</code> to stop the default caret blinking and allow the smooth animation to be seen. </p> <input type="text" class="custom-caret" value="I've got a custom caret animation" /> <input type="text" value="I've got the default blinking caret" />
We first define a set of @keyframes that change the caret-color from transparent to darkblue.
@keyframes custom-caret-animation {
from {
caret-color: transparent;
}
to {
caret-color: darkblue;
}
}
We then style the <p> and the first <input> with the custom @keyframes animation, a caret-color, and a caret-animation value of manual to turn the default caret blinking behavior off.
.custom-caret {
animation: custom-caret-animation infinite linear alternate 0.75s;
caret-color: darkblue;
caret-animation: manual;
}
p,
input {
font-size: 1.6rem;
}
The rendered result looks like so:
Try focusing the first two elements to see what the custom caret animation looks like. To compare it with the default blinking caret, you can focus the third element.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
caret-animation |
140 | No | No | 124 | No | 140 | No | No | No | No | 140 | No |
auto |
140 | No | No | 124 | No | 140 | No | No | No | No | 140 | No |
manual |
140 | No | No | 124 | No | 140 | No | No | No | No | 140 | No |
caret-color, caret-shape
caret shorthand
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/caret-animation