CSS "currentColor"
#10 · 2021-01-22 · CSScurrentColor
is a predefined color name.
But it has a special meaning:
The
currentcolor
keyword represents the value of an element'scolor
property. This lets you use thecolor
value on properties that do not receive it by default.
If an element has a color
assigned, you can "inherit" that specific color with the currentColor
keyword.
Given the code below, all paragraphs would have a border on the left.
The border color would be blue, unless you apply the red
class which would change both the color and the border color to red.
p {
color: blue;
border-left: 0.5em solid currentColor;
}
p.red {
color: red;
}