English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules

Complete List of CSS Attributes

CSS color Attribute Usage and Examples

The color CSS attribute sets the color of the text content of the element.

The following table provides usage instructions and version history of this attribute, as well as the syntax of using this attribute in JavaScript scripts.

Default Value:Depends on Browser
Applicable To:All Elements
Inheritance:Yes
Animatable:

Yes.ViewAnimation Attributes.

Version:CSS 1,2,3
JavaScript Syntax:object.style.color="#0000CC"

color Usage Syntax

The syntax of this attribute is as follows:

color: color | initial | inherit

The following examples demonstrate how to use the color attribute.

  body {
   color: red;
  }
  h1 {
   color: #00ff00;
  }
  p {
   color: rgb(0,0,255);
  }
Test and See‹/›

Attribute Value

The following table describes the value of this attribute.

ValueDescription
colorAccepts any validCSS Color Values.
initialSet this attribute to its default value.
inheritIf specified, the associated elements will adopt the color attribute value of their parent element.

Browser Compatibility

Browser Compatibility of color Attribute, the numbers in the table below represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 3+

  • Apple Safari 1+

  • Opera 3.5+

Further Reading

See Tutorial:CSS Color.

Related Attributes: background