CSS Reference

"color" - css property (v. css 1)

  • Sets the color of a text.
  • Initial value: depends on the browser and the HTML-element
  • The property is inherited
  • HTML usage: all elements
  • Browsers that support the color - property :
    Internet Explorer Mozilla Firefox Opera Google Chrome Apple Safari

Possible color values:

values Comments CSS
Color name HTML and CSS color specification defines 147 color names (17 standard colors plus 130 more). You find all the named color through the drop-down selection in the color picker below. 1
rgb(r,g,b) Integer values representing a color in the form of Red Green and Blue components each with a value between 0 - 255. (rgb(255,0,0) gives a red color) 1
#value A hexadecimal value representing a color in the form of Red Green and Blue components each with a value between 00 - FF. 1
inherit Will inherit the value from parent specification. This property value is new with CSS 2. 2
Color picker:

Selected Color:

Hex:
Red:
Green:
Blue:
Hue:
Saturation:
Value:
Harmonious colors:

Property "color" example:

<!DOCTYPE HTML >
<html  >
  <head>
    <title>Test</title>
    <script type="text/javascript" >
    </script>
    <style   type="text/css">
      .clip1 { position: absolute;
               clip: rect(0px, 139px, 50px, 55px);
               left: -50px;
      }

    </style>
  </head>
  <body >
    <img src="images/Sun.gif" border="0" alt=""/>
    <br/><br/>
    clip: rect(0px, 139px, 50px, 55px)<br/>
    and moved -50px in x-direction;
    <div class="clip1" >
      <img src="images/Sun.gif"
           border="0" alt=""/>
    </div>
  </body>
</html>

Javascript access:

// To SET values ([o] is the target object)
[o].style.color="color value"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null)
// To GET the property value:;
var value=cStyle.color;
/* IE and Opera will return a hexa-decimal string value (ex.: #FFFFFF) Firefox, Chrome and Safari will return a rgb string value (ex.: rgb(255,255,255))*/
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.