color
Description
color
property sets the foreground color of an element.
It is usually setting text of an element.
Item | Value |
---|---|
Inherited | Yes. |
Version | CSS1 |
JavaScript syntax | object.style.color="#FF0000" |
Applies to | All elements. |
Syntax and Property Values
color: color | inherit
The property values are listed in the following table.
Value | Description |
---|---|
color | Set the text color. |
inherit | Inherit the color from the parent element |
Example
The following code uses different color values.
strong {color: rgb(255,128,128);}
h3 {color: navy;}
p.warning {color: #ff0000;}
pre.pastoral {color: #0f0;}
To add color for a paragraph.
<html>
<head>
<style>
.style1 {<!--from w ww . j a v a 2 s. com-->
color: purple
}
</style>
</head>
<body>
<p class="style1">A color style rule has
been applied to this text.</p>
</body>
</html>
The code above generates the following result.