Course contentsShow
← Web Development
Lesson 185 of 2,9823. CSS FundamentalsFree lesson

The currentColor Keyword

Use the currentColor keyword to reference an element's computed color value in borders, fills, and other properties.

The currentColor Keyword

What you'll learn: How to reuse an element's computed text color value in other CSS properties using the currentColor keyword.


What Is currentColor?

The currentColor keyword is a special CSS value that refers to the computed color property of an element (or its inherited value). Think of it as a variable that automatically captures whatever text color is currently active on an element, allowing you to reuse that exact color in other properties like border, background, or box-shadow.

It's like telling your border: "Just match whatever color the text is using" — so if the text color changes, the border automatically updates too.

How It Works

Wherever you can use a color value, you can use currentColor. The browser will look at the element's color property and substitute that value.

.button {
  color: rgb(25, 100, 200);
  border: 2px solid currentColor;
}

Here, the border will be rgb(25, 100, 200) — matching the text color exactly.

Why Use It?

Using currentColor creates automatic consistency. If you later change the text color, all properties using currentColor update automatically:

.button {
  color: hsl(200, 75%, 50%);
  border: 3px solid currentColor;
  /* border is now hsl(200, 75%, 50%) */
}

.button:hover {
  color: hsl(200, 75%, 35%);
  /* border automatically darkens to match! */
}

No need to update multiple properties — one color change propagates everywhere.

Key Takeaway: The currentColor keyword lets you reference an element's computed text color in other CSS properties, creating automatic color consistency and reducing repetition.