This Season
 

How to Express RGB Colors as an Integer

How to Express RGB Colors as an Integerthumbnail
RGB colors can be expressed as integers.

On a web page, colors are displayed in RGB values, that is, by varying amounts of red, green and blue. All colors on the web are made from variations in the amount of red, green and blue assigned to any color. There are several ways to express this amount, one of which is with an integer value. Here is how.

Related Searches:
    Difficulty:
    Moderately Easy

    Instructions

    Things You'll Need

    • A web page
    • A style sheet for your web page
      • 1

        The RBG colors are normally given in a CSS rule in a style sheet for a particular web page. The syntax is
        rgb (color). When using integers to express color values, the value can range from 0 to 255.

      • 2

        In the parentheses where the color values are given, use three comma-separated integers: one for red, one for green and one for blue. Here, for example, is the value for white:
        rgb(255,255,255)

      • 3

        To use this color notation in a CSS rule, give the selector, then state the rgb value for the color property of the selector. Here's an example that would create a red color for an h2 selector:
        h2 {color: rgb(255,0,0);}

      • 4

        Here are some additional color values as integers:
        rgb(0,0,0) black
        rgb(255,102,0) orange
        rgb(255,255,0) yellow
        rgb(0,128,0) green
        rgb(0,0,255) blue
        rgb(0,255,255) aqua
        rgb(128,128,128) gray
        rgb(0,255,0) lime
        rgb(128,0,128) purple

    Tips & Warnings

    • Computers and browsers that use CSS understand this method of displaying colors.

    Related Searches

    Resources

    Read Next:

    Comments

    You May Also Like

    Follow eHow

    Related Ads