color
Example
.btn {
color: #0a66c2;
border: 1px solid #0a66c2;
}
.btn svg {
fill: #0a66c2;
}.btn {
color: #0a66c2;
border: 1px solid currentcolor;
}
.btn svg {
fill: currentcolor;
}currentcolor reuses the text color, so one change to color updates the border and icon too.
Common mistakes
- Light gray text on white looks clean but fails contrast checks.
- Link color doesn't change because the browser's default
astyles override inheritedcolor.
Key points
- Text and background colors are set together and meet contrast requirements for body text.
- Icons, borders and SVG fills that match the text use
currentcolorinstead of repeating the value. - Colors come from custom properties or tokens, not hardcoded hex values in every rule.
Interview questions
Is the color property inherited?
Yes. Children use the parent's color unless they set their own, but links and form controls have their own browser defaults.
How do I change the color of an SVG icon with CSS?
For inline SVG, set fill: currentcolor on the icon and change color on the parent.
Does color change the background?
No. color sets the text and currentcolor; use background-color for the background.