CSS caret-animation Property
The caret-animation property controls whether the browser automatically blinks the text insertion caret in editable content.
The insertion caret is the indicator showing where typed text will appear in a text input, textarea, or editable element. Normally, the browser controls its blinking behavior. The caret-animation property allows developers to retain that behavior or disable automatic blinking so the caret can be styled with CSS animations.
This property is part of CSS Basic User Interface Module Level 4 and has limited availability in browsers. It does not control the mouse pointer or text selection highlight.
caret-animation Syntax
Use caret-animation to select automatic or manual caret animation behavior.
selector {
caret-animation: manual;
}
The general syntax is:
selector {
caret-animation: auto | manual;
}
Automatic Caret Animation
input {
caret-animation: auto;
}
Manual Caret Animation
input {
caret-animation: manual;
}
Apply to a Textarea
textarea {
caret-animation: manual;
}
Apply to Editable Content
[contenteditable="true"] {
caret-animation: manual;
}
CSS-Wide Keywords
input {
caret-animation: inherit;
}
input {
caret-animation: initial;
}
input {
caret-animation: unset;
}
input {
caret-animation: revert;
}
input {
caret-animation: revert-layer;
}
The property accepts one keyword per declaration. It does not accept a duration, timing function, or animation name directly.
Property Values
The caret-animation property has two primary values.
| Value | Description |
|---|---|
auto |
Allows the browser to control its normal caret blinking behavior. This is the initial value. |
manual |
Disables the browser's automatic caret blinking so the caret can be controlled through CSS styling and animation. |
CSS-Wide Keywords
| Value | Description |
|---|---|
inherit |
Uses the computed value from the parent element. |
initial |
Resets the property to auto. |
unset |
Resets the property to auto because it is not inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | No |
| Applies to | Elements that can display a text insertion caret |
| Computed value | Specified keyword |
| Animation type | Discrete |
| Percentages | Not applicable |
| Shorthand | caret |
| Primary use | Controlling automatic caret blinking |
The property does not define the speed of the browser's automatic blinking. Use CSS animation properties when custom timing is needed and manual caret control is supported.
How It Works
Browsers normally display a blinking insertion caret when an editable element has focus.
Step 1: Create a Text Input
<input type="text" class="custom-input" placeholder="Enter text">
Step 2: Use Automatic Animation
.custom-input {
caret-animation: auto;
}
The browser continues controlling the caret's normal blinking behavior.
Step 3: Disable Automatic Blinking
.custom-input {
caret-animation: manual;
}
In supporting browsers, the browser no longer applies its usual automatic blinking cycle.
Step 4: Set a Caret Color
.custom-input {
caret-color: #1769aa;
caret-animation: manual;
}
The caret uses the specified color while manual animation control is active.
Step 5: Add a CSS Animation
@keyframes custom-caret-blink {
50% {
caret-color: transparent;
}
}
.custom-input {
caret-color: #1769aa;
caret-animation: manual;
animation: custom-caret-blink 1s step-end infinite;
}
The animation alternates the caret color between blue and transparent in browsers that support the required caret features.
If the browser does not support caret-animation, its normal blinking behavior may continue.
Automatic Caret Animation
The auto value allows the browser to manage caret blinking.
input {
caret-animation: auto;
}
Default Behavior
Most browsers blink the insertion caret automatically when an editable control has focus.
Automatic Animation in a Textarea
textarea {
caret-animation: auto;
}
Automatic Animation in Editable Content
[contenteditable="true"] {
caret-animation: auto;
}
Browser-Controlled Timing
The browser determines the blinking interval and may adjust it according to platform settings or user preferences.
Reset to Automatic Behavior
.custom-input {
caret-animation: manual;
}
.default-input {
caret-animation: auto;
}
The second rule explicitly restores automatic caret behavior for elements with the default-input class.
When to Use auto
Use auto when normal browser caret behavior is preferred or when overriding a previous manual setting.
Because auto is the initial value, it generally does not need to be declared.
Manual Caret Animation
The manual value disables the browser's automatic caret blinking behavior in supporting browsers.
input {
caret-animation: manual;
}
Static Caret
.static-caret {
caret-color: #1769aa;
caret-animation: manual;
}
Without an additional animation, the caret can remain continuously visible while the input is active.
Manual Caret in a Textarea
textarea {
caret-color: #008855;
caret-animation: manual;
}
Manual Caret in Editable Content
.editable-area {
caret-color: #1769aa;
caret-animation: manual;
}
Combine with CSS Animation
.animated-caret {
caret-color: #1769aa;
caret-animation: manual;
animation: custom-caret-blink 1s step-end infinite;
}
The animation named custom-caret-blink must be defined with an @keyframes rule.
Manual Does Not Define an Animation
The manual keyword does not specify a duration, timing function, or keyframe sequence. It only changes how the browser handles automatic caret blinking.
When to Use manual
Manual control is useful for specialized text editors, terminal-style interfaces, and experiments with custom caret behavior.
Because browser support is limited, provide a usable default experience when the property is unavailable.
Custom Caret Blinking
CSS animations can control caret visibility by changing caret-color between a visible color and transparent.
Define the Keyframes
@keyframes caret-blink {
50% {
caret-color: transparent;
}
}
Apply the Animation
.custom-input {
caret-color: #1769aa;
caret-animation: manual;
animation: caret-blink 1s step-end infinite;
}
Change the Duration
.custom-input {
animation-duration: 1.2s;
}
Use Step-Based Timing
.custom-input {
animation-timing-function: step-end;
}
Step-based timing produces abrupt changes between visible and transparent states rather than a gradual color transition.
Control the Iteration Count
.custom-input {
animation-iteration-count: infinite;
}
Animate Only While Focused
.custom-input {
caret-color: #1769aa;
caret-animation: manual;
}
.custom-input:focus {
animation: caret-blink 1s step-end infinite;
}
Complete Example
@keyframes caret-blink {
50% {
caret-color: transparent;
}
}
.custom-input {
caret-color: #1769aa;
caret-animation: manual;
}
.custom-input:focus {
animation: caret-blink 1s step-end infinite;
}
This technique requires support for manual caret control and animating caret-color. Test the result because browser behavior can differ.
Using caret-color
The caret-color property controls the insertion caret's color independently of its automatic blinking behavior.
Blue Caret
input {
caret-color: #1769aa;
}
Green Caret
textarea {
caret-color: #008855;
}
Use the Current Text Color
input {
color: #333333;
caret-color: currentColor;
}
Combine Color and Manual Animation
input {
caret-color: #1769aa;
caret-animation: manual;
}
Color Animation
@keyframes caret-fade {
50% {
caret-color: transparent;
}
}
input {
caret-color: #1769aa;
caret-animation: manual;
animation: caret-fade 1s step-end infinite;
}
Browser Compatibility
The caret-color property is widely supported, while caret-animation has more limited availability.
Use caret-color when you only need to customize the caret's color and do not need manual blinking control.
Using the caret Shorthand
The caret shorthand combines caret-color, caret-shape, and caret-animation.
Separate Properties
input {
caret-color: #1769aa;
caret-shape: bar;
caret-animation: manual;
}
Combined Shorthand
input {
caret: #1769aa bar manual;
}
Automatic Animation
input {
caret: #1769aa bar auto;
}
Manual Animation
input {
caret: #1769aa bar manual;
}
Omitted Values
input {
caret: #1769aa;
}
In supporting browsers, omitted shorthand components are reset to their initial values.
Longhand Override
input {
caret: #1769aa bar auto;
caret-animation: manual;
}
The later declaration changes the animation component without replacing the other caret settings.
Compatibility Considerations
The complete caret shorthand is not supported consistently across browsers. Use individual longhand properties when broader compatibility or more precise control is required.
Form Controls
The caret-animation property is relevant to form controls that display an insertion caret.
Text Input
input[type="text"] {
caret-animation: manual;
}
Email Input
input[type="email"] {
caret-animation: manual;
}
Search Input
input[type="search"] {
caret-animation: manual;
}
Textarea
textarea {
caret-animation: manual;
}
Combined Controls
input,
textarea {
caret-color: #1769aa;
caret-animation: manual;
}
Apply Only While Focused
input:focus,
textarea:focus {
caret-animation: manual;
}
Keep Default Behavior
input,
textarea {
caret-color: #1769aa;
caret-animation: auto;
}
Normal browser-controlled blinking is generally the most dependable choice for standard forms.
The property does not create an insertion caret in controls such as buttons, checkboxes, or radio buttons.
Editable Content
Elements using the HTML contenteditable attribute can display an insertion caret and may be styled with caret-animation.
Editable Element
<div class="editable-box" contenteditable="true">
Click here to edit this text.
</div>
Manual Caret Control
.editable-box {
padding: 12px;
border: 1px solid #cccccc;
caret-color: #1769aa;
caret-animation: manual;
}
Editable Code Area
<div class="code-editor" contenteditable="true" spellcheck="false">
Edit this sample text.
</div>
.code-editor {
padding: 15px;
color: #eeeeee;
background-color: #222222;
font-family: monospace;
caret-color: #66ccff;
caret-animation: manual;
}
Add Custom Animation
@keyframes editor-caret-blink {
50% {
caret-color: transparent;
}
}
.code-editor:focus {
animation: editor-caret-blink 1s step-end infinite;
}
Maintain a Visible Focus Indicator
.editable-box:focus-visible {
outline: 2px solid #1769aa;
outline-offset: 2px;
}
The focus outline identifies the active editing area, while the insertion caret identifies where typed text will appear.
Manual caret animation should not interfere with normal keyboard editing or text selection behavior.
Reduced Motion
Custom caret animation should respect users who prefer reduced motion.
Detect Reduced Motion Preferences
@media (prefers-reduced-motion: reduce) {
.custom-input {
animation: none;
}
}
Complete Reduced Motion Example
@keyframes caret-blink {
50% {
caret-color: transparent;
}
}
.custom-input {
caret-color: #1769aa;
caret-animation: manual;
animation: caret-blink 1s step-end infinite;
}
@media (prefers-reduced-motion: reduce) {
.custom-input {
animation: none;
}
}
In supporting browsers, the custom animation is disabled when the user requests reduced motion.
Preserve Caret Visibility
When disabling custom animation, ensure that the caret remains visible and easy to locate.
Avoid Excessive Blinking
Rapid or unusual blinking can make text entry distracting. Prefer the browser's default caret behavior unless custom animation provides a clear benefit.
Accessibility Recommendation
For ordinary form fields, use caret-animation: auto or omit the property entirely. The browser's default behavior is generally better integrated with platform accessibility preferences.
Feature Detection
The @supports rule can check whether a browser recognizes the caret-animation property.
Basic Feature Detection
@supports (caret-animation: manual) {
.custom-input {
caret-animation: manual;
}
}
Add Animation Only When Supported
.custom-input {
caret-color: #1769aa;
}
@supports (caret-animation: manual) {
.custom-input {
caret-animation: manual;
animation: caret-blink 1s step-end infinite;
}
}
Include the Keyframes
@keyframes caret-blink {
50% {
caret-color: transparent;
}
}
Combine with Reduced Motion
@media (prefers-reduced-motion: reduce) {
.custom-input {
animation: none;
}
}
Fallback Behavior
When caret-animation is unsupported, the browser ignores the declaration and uses its normal caret blinking behavior.
Feature detection confirms that the declaration is recognized, but it does not guarantee identical rendering across browser engines.
Practical Uses
The caret-animation property is most useful when an interface requires more control over caret blinking than the browser normally provides.
Static Caret
.static-caret {
caret-color: #1769aa;
caret-animation: manual;
}
Custom Blinking Speed
.custom-caret {
caret-color: #1769aa;
caret-animation: manual;
animation: caret-blink 1.2s step-end infinite;
}
Dark-Themed Editor
.dark-editor {
color: #eeeeee;
background-color: #222222;
caret-color: #66ccff;
caret-animation: manual;
}
Terminal-Style Input
.terminal-input {
color: #00cc66;
background-color: #111111;
caret-color: #00cc66;
caret-shape: block;
caret-animation: manual;
}
The block shape requires separate caret-shape support.
Custom Editable Area
.editable-area {
caret-color: #1769aa;
caret-animation: manual;
}
Restore Default Blinking
.standard-input {
caret-animation: auto;
}
Reduced Motion Alternative
@media (prefers-reduced-motion: reduce) {
.custom-caret {
animation: none;
}
}
Use manual caret animation sparingly and preserve a readable insertion indicator in every supported state.
caret-animation Example
The following example compares automatic caret blinking with manual caret control. Click inside each field to observe the insertion caret.
The second field uses caret-animation: manual and a CSS animation that changes caret-color. If the property is unsupported, the browser may continue using its default caret behavior.
<div class="caret-animation-demo">
<label for="auto-caret">Automatic Caret Animation</label>
<input type="text" id="auto-caret" class="auto-caret" placeholder="Click to type">
<label for="manual-caret">Manual Caret Animation</label>
<input type="text" id="manual-caret" class="manual-caret" placeholder="Click to type">
</div>
@keyframes demo-caret-blink {
50% {
caret-color: transparent;
}
}
.caret-animation-demo label {
display: block;
margin-bottom: 6px;
font-weight: bold;
}
.caret-animation-demo input {
display: block;
width: 100%;
box-sizing: border-box;
margin-bottom: 15px;
padding: 10px;
border: 1px solid #cccccc;
border-radius: 4px;
caret-color: #1769aa;
}
.caret-animation-demo .auto-caret {
caret-animation: auto;
}
@supports (caret-animation: manual) {
.caret-animation-demo .manual-caret {
caret-animation: manual;
animation: demo-caret-blink 1.2s step-end infinite;
}
}
.caret-animation-demo input:focus-visible {
outline: 2px solid #1769aa;
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.caret-animation-demo .manual-caret {
animation: none;
}
}
The first field uses the browser's normal caret blinking. The second requests manual control and applies a custom blinking animation when supported.
The custom animation is disabled when the user has requested reduced motion. Browser support determines whether the two fields display visibly different blinking behavior.
Important Considerations
Keep the following points in mind when using caret-animation:
- Purpose: Controls whether the browser automatically blinks the insertion caret.
- Initial value:
auto. - Inheritance: The property is not inherited.
- Automatic behavior:
autoallows normal browser-controlled blinking. - Manual behavior:
manualdisables automatic blinking in supporting browsers. - Animation timing: The property does not directly accept a duration or timing function.
- Custom blinking: CSS animations can change
caret-colorto control caret visibility. - Editable elements: The property is relevant to text inputs, textareas, and editable content.
- Browser support: The property has limited availability compared with
caret-color. - Feature detection: Use
@supportswhen adding custom caret effects. - Fallback: Preserve the browser's normal caret behavior when the property is unsupported.
- Reduced motion: Respect
prefers-reduced-motionwhen adding custom animation. - Accessibility: Keep the insertion caret visible and easy to locate.
- Focus indicators: The caret does not replace a visible keyboard focus outline.
- Shorthand: The property is included in the
caretshorthand. - Mouse pointer: The property does not control the mouse cursor.
- Text selection: The property does not style selected text.
- Testing: Check custom caret behavior in the browsers and operating systems your website supports.
For most form controls, normal browser caret blinking is sufficient. Use caret-animation: manual only when custom caret behavior provides a practical benefit and is supported by the target browsers.
Browser Support
The caret-animation property has limited availability. Some modern browsers support it, while others may ignore the declaration and continue using their normal caret blinking behavior.
Because this property is newer than caret-color, custom animation techniques should be treated as progressive enhancements rather than essential functionality.
Feature Detection
@supports (caret-animation: manual) {
.custom-input {
caret-animation: manual;
}
}
Compatible Fallback
.custom-input {
caret-color: #1769aa;
}
@supports (caret-animation: manual) {
.custom-input {
caret-animation: manual;
}
}
The caret color remains available in browsers that support caret-color, even when manual animation control is unavailable.
For current compatibility details, visit Can I Use? and search for caret-animation.
Specifications
The caret-animation property is defined in the CSS Basic User Interface Module Level 4 specification.
CSS Basic User Interface Module Level 4
The specification defines how automatic caret blinking can be disabled to allow CSS-controlled caret animation.
