# color

> The `color` CSS property sets the color of text content.

## How do I change text color in CSS?

The property that sets the color of text in an element. It applies to the content of the element, including text, borders and other inline elements and can be defined using color keywords, hexadecimal values, RGB, HSL or other color functions.

- Topic: Text Handling
- Type: property
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 1+, Safari iOS 1+

## Example

Wrong:

```css
.btn {
  color: #0a66c2;
  border: 1px solid #0a66c2;
}
.btn svg {
  fill: #0a66c2;
}
```

Right:

```css
.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 `a` styles override inherited `color`.

## 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 `currentcolor` instead 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.

## Related cards

- [currentcolor](https://wonderium.dev/css/currentcolor.md)
- [background-color](https://wonderium.dev/css/background-color.md)
- [Inheritance](https://wonderium.dev/css/inheritance.md)
- [oklch()](https://wonderium.dev/css/oklch.md)
- [WCAG](https://wonderium.dev/a11y/wcag.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/color-property
- Last updated: 2026-11-25
