CSS color Property
The color property sets the foreground color value of an element’s text content and text decorations.
Description & Usage
The color property defines text and text-decoration color for an element.
Because color is an inherited property, setting color on body or a top-level wrapper applies to all child text nodes unless overridden.
Modern CSS supports hex (#2563eb), rgb/rgba(), hsl/hsla(), and CSS custom property variables for theme toggles.
Property Specifications
| Property Feature | Specification |
|---|---|
| Category | Typography |
| Initial Value | CanvasText / black |
| Inherited | Yes (inherited from parent) |
| Applies To | All elements |
Syntax
color: #0f172a | rgb(15, 23, 42) | hsl(222, 47%, 11%) | red;Property Values
| Value | Description |
|---|---|
| #2563eb | Hexadecimal color code for vibrant blue. |
| rgba(0,0,0,0.85) | RGB with alpha transparency. |
Code Examples
Setting Body Text Color
body {
color: #1e293b;
background-color: #ffffff;
}
Applies readable dark grey text across all child elements.