caret-color

CSS caret-color 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 flash. By default, this caret is black. However, the caret-color property allows applying any color to the caret.

类目类目
Initial Valueauto
Applies toAll elements.
InheritedYes.
AnimatableNo.
VersionCSS3
DOM Syntaxobject.style.caretColor = “#1c87c9”;

Syntax

Syntax

caret-color: auto | color;

Example of the caret-color property:

<!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>

Faking the caret-color property

Faking the caret-color property

There exists a method of faking it by making the text transparent with the help of the -webkit-text-fill-color property and using the text-shadow property make the text to show back up, coloured.

Values

Values

ValueDescription
autoSets the current color of the text. This is the default value.
colorSpecifies a color for the caret.
initialIt makes the property use its default value.
inheritIt inherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部