caret-color
Quick Summary for caret-color
The caret-color CSS property sets the color of the insertion caret, the visible marker where the next character typed will be inserted. This is sometimes referred to as the text input cursor. The caret appears in elements such as <input> or those with the contenteditable attribute. The caret is typically a thin vertical line that flashes to help make it more noticeable. By default, it is black, but its color can be altered with this property.
Code Usage for caret-color

<pre class="brush: css notranslate"><code><span class="token comment">/ Keyword values /</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> transparent<span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> currentcolor<span class="token punctuation">;</span> <span class="token comment">/ &lt;color&gt; values /</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> red<span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> #5729e9<span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> <span class="token function">rgb</span><span class="token punctuation">(</span>0<span class="token punctuation">,</span> 200<span class="token punctuation">,</span> 0<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> <span class="token function">hsla</span><span class="token punctuation">(</span>228<span class="token punctuation">,</span> 4%<span class="token punctuation">,</span> 24%<span class="token punctuation">,</span> 0.8<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">/ Global values /</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> inherit<span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> initial<span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> revert<span class="token punctuation">;</span> <span class="token property">caret-color</span><span class="token punctuation">:</span> unset<span class="token punctuation">;</span> </code></pre>

More Details for caret-color

caret-color

The caret-color CSS property sets the color of the insertion caret, the visible marker where the next character typed will be inserted. This is sometimes referred to as the text input cursor. The caret appears in elements such as <input> or those with the contenteditable attribute. The caret is typically a thin vertical line that flashes to help make it more noticeable. By default, it is black, but its color can be altered with this property.

Note that the insertion caret is only one type of caret. For example, many browsers have a "navigation caret," which acts similarly to an insertion caret but can be moved around in non-editable text. On the other hand, the mouse cursor image shown when hovering over text where the cursor property is auto, or when hovering over an element where the cursor property is text or vertical-text, though it sometimes looks like a caret, is not a caret (it's a cursor).

Syntax

/* Keyword values */ caret-color: auto; caret-color: transparent; caret-color: currentcolor;  /* <color> values */ caret-color: red; caret-color: #5729e9; caret-color: rgb(0, 200, 0); caret-color: hsla(228, 4%, 24%, 0.8);  /* Global values */ caret-color: inherit; caret-color: initial; caret-color: revert; caret-color: unset; 

Values

auto

The user agent selects an appropriate color for the caret. This is generally currentcolor, but the user agent may choose a different color to ensure good visibility and contrast with the surrounding content, taking into account the value of currentcolor, the background, shadows, and other factors.

Note: While user agents may use currentcolor (which is usually animatable) for the auto value, auto is not interpolated in transitions and animations.

<color>

The color of the caret.

Formal definition

Initial valueauto
Applies toall elements
Inheritedyes
Computed valueauto is computed as specified and <color> values are computed as defined for the color property.
Animation typea color

Formal syntax

auto | <color>

where <color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color>

where <rgb()> = rgb( <percentage>{3} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? ) | rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )<rgba()> = rgba( <percentage>{3} [ / <alpha-value> ]? ) | rgba( <number>{3} [ / <alpha-value> ]? ) | rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )<hwb()> = hwb( [<hue> | none] [<percentage> | none] [<percentage> | none] [ / [<alpha-value> | none] ]? )

where <alpha-value> = <number> | <percentage><hue> = <number> | <angle>

Examples

Setting a custom caret color

HTML
<input value="This field uses a default caret." size="64"/> <input class="custom" value="I have a custom caret color!" size="64"/> <p contenteditable class="custom">This paragraph can be    edited, and its caret has a custom color as well!</p> 
CSS
input {   caret-color: auto;   display: block;   margin-bottom: .5em; }  input.custom {   caret-color: red; }  p.custom {   caret-color: green; } 
Result

Specifications

Specification
CSS Basic User Interface Module Level 4 # caret-color

See also

The <input> element The HTML contenteditable attribute, which can be used to make any element's text editable Making content editable Applying color to HTML elements using CSS The <color> data type Other color-related properties: color, background-color, border-color, outline-color, text-decoration-color, text-emphasis-color, text-shadow, caret-color, and column-rule-color Select your preferred language English (US)EspañolFrançais日本語中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
In this case my anchor this week becomes driving almost 2hrs outside of Atlanta to one of my favorite hard core gyms in the world.. MetroFlex aka The Dungeon. The gym owners turn the heat way up so it becomes a fun sweat box and the gym members just watch from afar and leave me alone. I happily drive myself long distances to find MY ANCHOR. Our anchor allows us to have balance, focus and be as productive as possible. And if you're in the middle of a heavy set and your headphones start to fall off your head, like mine did here.. well.. f*ck the headphones. Let em break and fall. You can always get a new pair, but the iron ain't ever gonna lift itself.
Unknown
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.