English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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: | |
Version: | CSS 1,2,3 |
JavaScript Syntax: | object.style.color="#0000CC" |
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‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
color | Accepts any validCSS Color Values. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements will adopt the color attribute value of their parent element. |
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.
|
See Tutorial:CSS Color.
Related Attributes: background