CSS caret-color Property
The carter-color is a CSS property which specifies the color of the cursor. Find an example with this property.
The caret-color property specifies the color of the insertion caret (cursor). It is a thin vertical line, which is easily noticeable due to its blinking. By default, this caret is black. However, the caret-color property allows applying any color to the caret.
| Initial Value | auto |
|---|---|
| Applies to | Elements that accept text input. |
| Inherited | No. |
| Animatable | No. |
| Version | CSS3 |
| DOM Syntax | object.style.caretColor = "#1c87c9"; |
Syntax
Syntax of CSS caret-color Property
caret-color: auto | color;Example of the caret-color property:
Example of CSS caret-color Property with transparent and color value
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
.caret-example1 {
caret-color: transparent;
}
.caret-example2 {
caret-color: #1c87c9;
}
</style>
</head>
<body>
<h2>Caret-color property example</h2>
<input value="Default caret color" />
<br />
<br />
<input class="caret-example1" value="Transparent caret color" />
<br />
<br />
<input class="caret-example2" value="Custom caret color" />
</body>
</html>Values
| Value | Description |
|---|---|
| auto | Sets the current color of the text. This is the default value. |
| color | Specifies a color for the caret. |
| initial | It makes the property use its default value. |
| inherit | It inherits the property from its parent element. |
Practice
Practice
What is the function of the CSS caret-color property?