Monday, February 10, 2014

Colors, colors, colors, and colors!

In CSS, we use colors in text, backgrounds, borders, underlines, on and on and on. The most common way to specify a color is by giving its RGB value. RGB stands for red, green, and blue. You guessed it! You basically say how much red, green, and blue you want in that color!

There are four ways to give RBG values:

rgb (255, 255, 255)
rgb (100%, 100%, 100%)
#FFFFFF

#FFF

These all describe the color white. Let's look at the first one:

rgb (255, 255, 255)

The higher the number, the more light. 255 is the highest number you can specify for each color, and the most light means white. But why is 255 the highest number? Well, 8 bits (a bit in a computer is a 1 or 0) are used for providing the red value, and 8 bits can have 256 numbers (28=256), so the numbers range from 0 to 255, 0 being no red light, 255 meaning the most red light. The same is for blue and green.

rgb (100%, 100%, 100%)

The RGB values here are just specified using percentages, 0% being no light, 100% being the most.



#FFFFFF

and

#FFF

Are in hexidecimal, which we'll go over tomorrow.

No comments:

Post a Comment