CSS Text Color
The color property sets text color. Pick a text color and a
background below — the contrast ratio updates live, so you can see immediately
whether your text is readable.
A headline in your text color
Body text in the same color. If you can read this comfortably at a glance, the combination works. If you have to squint, the contrast is too low — darken the text or lighten the background.
Contrast ratio: —
WCAG AA needs 4.5:1 for normal text and 3:1 for large text (18pt+, or 14pt bold+). AAA needs 7:1 for normal text and 4.5:1 for large text.
How to change text color in CSS with the color property — with a live demo: pick a text color and background, see the contrast ratio update instantly, and copy the CSS.
The color property sets text color in CSS: p { color: #1F2937; }. Pick a text color and a background in the demo — the contrast ratio updates live, so you know immediately whether the text is readable.
The color property
color sets the color of text — and only text. It does not
change the background (that is background-color), the border
(that is border-color), or anything else. It is inherited: set it
on a parent element and all the text inside inherits it unless a child rule
overrides it.
body {
color: #1F2937; /* near-black: readable on white */
}
a {
color: #2563EB; /* links get their own color */
}Readability comes first
A beautiful text color that nobody can read is a failed text color. The rule is simple: normal body text needs a contrast ratio of at least 4.5:1 against its background to pass WCAG AA, the standard most sites aim for. Light gray text on white (#767676 scores about 4.54:1 and just passes; #999999 scores 2.85:1 and fails badly) is the most common mistake on the web. The demo above shows the ratio live — if it says Fail, darken the text or lighten the background until it passes.
Common text-color choices
| Use | Typical color | Why |
|---|---|---|
| Body text on white | #111111 or #1F2937 | Near-black is softer than pure black and still scores about 14.7:1 or better. |
| Secondary / muted text | #4B5563 or #6B7280 | Gray, but dark enough to stay readable — #6B7280 on white is 4.83:1. |
| Text on a dark background | #FFFFFF or #F9FAFB | White on near-black is the highest-contrast combination there is. |
| Error text | #B91C1C (dark red) | Red reads as an error, but bright red (#FF0000) on white is only 4:1 — use a dark red. |
Text color and links
Links are text too, but browsers give them their own default colors (blue
unvisited, purple visited) that override the inherited color.
Set link colors explicitly — the link colors
guide covers :link, :visited,
:hover, and :active with a live demo.
Frequently asked questions
How do I change text color in CSS?
Use the color property: p { color: #1F2937; }. It sets the color of the text inside the element, and child elements inherit it unless they set their own color.
What is a good text color for a white background?
Near-black: #111111 (18.88:1) or #1F2937 (14.68:1). Pure black #000000 is the highest contrast at 21:1, but near-black looks softer. Avoid light gray — #999999 on white is only 2.85:1 and fails WCAG AA.
What contrast ratio does text need?
WCAG AA needs 4.5:1 for normal text and 3:1 for large text (18pt or larger, or 14pt bold and larger). AAA needs 7:1 for normal text and 4.5:1 for large text. The demo above checks your pair live.
Does color affect the background too?
No. The color property only affects text (and the text-decoration underline color). The background is background-color, covered in the background-color guide.
Related tools
CSS Background Color · CSS Link Color · CSS Color Basics · Contrast Checker · What Is a Hex Code?