CSS Color

The color property allows webmasters to define the color of an element in a CSS stylesheet.

This property takes values in 3 forms:

  • Hexadecimal code
  • RGB
  • Color nameThe general syntax for the color property is as follows:

    Hexadecimal code:

    {color:#XXXXXX;}

    where X is a hexadecimal code.

    RGB:

    {color:rgb(X,Y,Z); }   where X, Y, and Z are numbers between 0 and 255
    OR
    {color:rgb(X%,Y%,Z%); }   where X, Y, and Z are numbers between 0 and 100.

    Color name:

    {color:[color_name];}

    Hexadecimal code is a 6-character (or 3-character when the first two, the middle two, and the last two codes of the 6-character presentation are all the same. For example, #FFF and #FFFFFF both mean white) code specifying the color. This hexadecimal color chart shows how hexadecimal codes correspond to the colors they render.

    Below are examples showing how each form described above can be used to specify a color.

    CSS Declaration Output
    p {color:#FF0000;} FF0000 is red.
    p {color:rgb(255,0,255);} rgb(255,0,255) is pink.
    p {color:green;} This is green.

     

Add your comment