Definition and Usage
The currentcolor keyword is a CSS keyword that represents the text color of the current element (the computed value of the color property).
The keyword currentcolor combines "current", meaning present, with the name of the color property, which specifies the text color of the element. In other words, it refers to the text color of the current element.
This keyword is useful when you want to apply the current element's text color to other properties as well.
Good to Know!
In many CSS codebases, currentcolor and currentColor are used interchangeably.
Both forms represent the same value.
CSS does not distinguish between the lowercase c and uppercase C in this keyword.
Basic Example
p {
color: blue;
border-width: 5px;
border-style: solid;
border-color: currentcolor; /* Current text color */
}
<p>The current text color of the p element is blue.</p>
<p>The p element's border-color is currentcolor (current text color).</p>
The current text color of the p element is blue.
The p element's border-color is currentcolor (current text color).
As shown in the example above, the text color of the <p> element is set to blue using the color property.
If you set the value of the border-color property, which specifies the element's border color, to currentcolor, it is set to blue, which is specified as the current text color of this element.
CSS Properties Whose Initial Value Is currentcolor
There are more CSS properties than you might expect whose initial value is currentcolor. Let's look at some examples.
The text-decoration-color Property
The text-decoration-color property sets the color of the line decorations specified by the text-decoration-line property used on text. If no color is specified, its initial value is currentcolor.
<p>text-decoration-color property</p>
p {
color: orangered;
text-decoration-line: underline;
}
p:hover {
color: blue;
}
text-decoration-color property
In the example above, the text-decoration-color property is not specified. In this case, currentcolor, the initial value of the text-decoration-color property, is set to the current text color, orangered. When you hover over this element (:hover), currentcolor changes to blue, the color specified for the hover state.
The box-shadow Property
The box-shadow property applies a shadow effect to an element's box. If no shadow color is specified, its initial value is currentcolor.
<div class="box">box</div>
.box {
color: orangered;
box-shadow: 5px 5px 10px;
width: 200px;
height: 100px;
}
.box:hover {
color: blue;
}
As in the example above, when no shadow color is specified for the box-shadow property, its initial value, currentcolor, is set to the current text color, orangered. When you hover over this element (:hover), currentcolor changes to blue, the color specified for the hover state.
Other Properties
Here are some other notable CSS properties whose initial value is currentcolor when specifying colors in CSS.
Browser Compatibility
| Keyword |
Desktop Chrome
|
Desktop Edge
|
Desktop Firefox
|
Safari
|
|---|---|---|---|---|
currentcolor
|
1 | 12 | 4 | 4 |
Specifications
| Specification | |
|---|---|
currentcolor
|
CSS Color Module Level 4 #valdef-color-currentcolor |