color

Description

color property sets the foreground color of an element. It is usually setting text of an element.

ItemValue
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>

Click to view the demo

The code above generates the following result.

color




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference