CSS color Property

Example

Set the text-color for different elements:

body {
  color: red;
}

h1 {
  color: #00ff00;
}

p.ex {
  color: rgb(0,0,255);
}

Definition and Usage

The color property specifies the color of text.

Tip: Use a background color combined with a text color that makes the text easy to read.

Default value: not specified
Inherited: yes
Animatable: yes.
Version: CSS1
JavaScript syntax: object.style.color="#0000FF"

  • Inherited : "Inherited = yes" means that it can takes (inherit) it's value from it's parent element.
  • object - object in javascript means the element on which color is applied.
  • Animatable - "Animatable = yes" means that it can be animated with CSS @keyframes.

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property          
color 1.0 3.0 1.0 1.0 3.5

CSS Syntax

color: color|initial|inherit;

Property Values

Value Description Demo
color Specifies the text color.
initial Sets this property to its default value.  
inherit Inherits this property from its parent element.  

More Examples

Example

Set the text color with a HEX value:

body {color: #92a8d1;}

Example

Set the text color with an RGB value:

body {color: rgb(201, 76, 76);}

Example

Set the text color with an RGBA value:

body {color: rgba(201, 76, 76, 0.6);}

Example

Set the text color with a HSL value:

body {color: hsl(89, 43%, 51%);}

Example

Set the text color with a HSLA value:

body {color: hsla(89, 43%, 51%, 0.6);}

Comments

Most Reads