The color property sets the foreground color of an element’s text and text decorations. It also defines currentColor, which other properties can reuse (for example border-color).
It does not paint the background — that is background-color. The property is inherited, so one rule on a parent can color nested text.
Baseline · Widely available.
Not deprecated and not experimental. Supported everywhere modern browsers run, including Internet Explorer for classic color values.
Syntax
CSS Syntax
syntax.css
color:<color> | currentColor | initial | inherit;
A <color> can be a name (red), hex (#2563eb), rgb(), hsl(), and more. The initial value is canvastext. The property is inherited.
Set the text color.color: #0f766e is the source value.
Point the border at it.currentColor reads that computed color.
One change, two places. Updating color updates the border too.
Default for many color props. Several properties already default to currentColor.
Edge Cases & Pitfalls
If the text looks wrong, check these first.
contrast
Low contrast is hard to read
Aim for about 4.5:1 contrast for normal text (WCAG). Light gray on white fails many readers.
background
color is not the background
Use background-color to fill behind text. Mixing them up is a common beginner mistake.
inherit
It inherits by default
Children take the parent’s color. Override on the child when you need a different shade.
currentColor
color: currentColor means inherit
When used as the value of color itself, currentColor is treated like inherit.
opacity
opacity fades the whole element
opacity affects text and background together. Prefer an alpha in the color value when only the text should be translucent.
Compatibility
Browser Support
color is a browser CSS property for text and foreground color. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
color
Classic values (names, hex, rgb, hsl) work in all major browsers, including Internet Explorer. Newer spaces like oklch need modern browsers.
99%Classic value support
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera3.5+
Full support
Samsung Internet1+
Full support
Internet Explorer3+
Full support (classic values)
color (classic values)Universally supported
Bottom line: Safe everywhere for names, hex, rgb, and hsl. Use newer color functions only when you can require modern browsers. It is not a runtime API.
Remember
Key Takeaways
Role: set text (and decoration) color; define currentColor.
Formats: names, hex, rgb(), hsl(), and more.
Inherited: children follow the parent unless you override.
Accessibility: keep strong contrast with the background.
One line:color: #2563eb; paints the text; pair it with a contrasting background.
Frequently Asked Questions
It sets the foreground color of text and text decorations, and defines currentColor for other properties such as border-color when they use that keyword.
The initial value is canvastext, which is usually a dark text color in light mode. color is inherited, so children pick up the parent’s text color unless you override it.
color styles text and decorations. background-color paints behind the content. Use both with enough contrast for readable text.
currentColor means “use this element’s computed color.” Borders, outlines, and SVGs can match the text with border-color: currentColor. If you set color: currentColor, it behaves like inherit.
Aim for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (WCAG). Dark text on a light background, or the reverse, is the usual pattern.
It is Baseline Widely available and works in all major browsers, including Internet Explorer. Newer color functions have wider modern support. It is a browser CSS property, not a Node.js feature.