How does currentColor let CSS reuse an element’s text color?
Quick answer
The question, the details, the next step.
A practical checklist
Identify the element whose text and other details should share a color.
Find the
colorthat applies to that element, including any inherited value.Set border or outline width and style separately as needed.
Change the element’s color during review and check whether the coordinated details follow.
A few more useful answers
What happens if I set `color: currentColor`?
For the color property itself, currentColor is treated as inherit. [S1] To make a border or outline follow the text color, use currentColor on that other property.
Can `currentColor` be used for properties other than borders and outlines?
Does `currentColor` set an outline’s width or style?
No. It supplies the outline color; set width and style separately when needed. [S2]
Sources
References used for this guide.
- [S1] MDN: CSS color property and the currentColor value developer.mozilla.org · Checked
- [S2] MDN: CSS outline-color property developer.mozilla.org · Checked
