How to use color in css

The color property sets the color of an element’s text content, and its decorations. It doesn’t affect any other characteristic of the element.The color value must be a uniform color, which may include a transparency value from CSS3.

Colors in CSS could be specified by:

  1.  color name – like “red”
  2. RGB value – like “rgb(255, 0, 0)”
  3. HEX value – like “#ff0000”

For example:

<h2 style=”background-color:rgb(255, 0, 0)”> RGB value </h2>

<h2 style=”background-color:#ff0000″> HEX Value </h2>

<h2 style=”background-color: green”> Color Name value</h2>

RGB (Red, Green, Blue)

RGB color values can be specified using this formula: rgb(red, green, blue).
Each parameter (red, green, blue) defines the intensity of the color between 0 and 255.
For example, rgb(255,0,0) is displayed as red, because red is set to its highest value (255) and the others are set to 0.

 

Hexadecimal Colors

RGB values can also be specified using hexadecimal color values in the form: #RRGGBB, where RR (red), GG (green) and BB (blue) are hexadecimal values between 00 and FF (same as decimal 0-255).
For example, #FF0000 is displayed as red, because red is set to its highest value (FF) and the others are set to the lowest value (00).

Leave a Reply

Your email address will not be published.

*