Current color and system colors
Definition and purpose
currentColor refers to the element’s computed color when used by other color-taking properties. System colors such as Canvas and CanvasText depend on the environment.
Shared border color
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { color: navy; border: 2px solid currentColor; } #b { color: green; border: 2px solid currentColor; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>Each border follows its own text color.
Syntax and mental model
Set color once and reuse it for borders, outlines or SVG fills where appropriate. On the color property itself, currentColor behaves as inherited color. System foreground/background pairs help respect user palette choices; their numerical RGB values are not fixed.
System palette
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { color: CanvasText; background-color: Canvas; } #b { color: CanvasText; background-color: Canvas; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>In this controlled light browser palette the pair is black on white; other environments may differ.
Common mistakes
Do not treat CanvasText as always black. Test forced colors, and keep meaningful text and focus cues.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: HSL and alpha compositing. Next lesson: Contrast and color scheme.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Current color and system colors — knowledge check
Five questions on current color and system colors.
What does currentColor resolve from on a border?
What happens when color changes?
Is CanvasText always black?
Which is a system background keyword?
Which combination is appropriate for system palette text?