B.24. color

This property sets the foreground (text) color of the element. This property also defines the default border color of the element.

In general, you should always specify a background color when you specify a foreground color, and vice versa.

Inherited: Yes

See also: Section B.4background-color

B.24.1. Value

Any CSS color value (see Appendix D).

Initial value: black

B.24.2. Compatibility

CSS Version: 1

Works in all CSS-compatible browsers including Internet Explorer 4 or later, Netscape 4 or later, and Mozilla browsers.

B.24.3. Example

This style rule sets paragraphs of class warning to have white text on a tomato red background.

p.warning {
  color: white;
  background-color: #ff6347;
}

Get HTML Utopia: Designing Without Tables Using CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.