O'Reilly logo

Web Programming with HTML5, CSS, and JavaScript by Dean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.14 RGB Values for Color

RGB stands for red, green, and blue. An RGB value specifies the amounts of red, green, and blue that mix together to form the displayed color. To specify an amount of a color, you can use a percentage, an integer, or a hexadecimal number (we’ll explain hexadecimal shortly). We’ll provide explanations and examples coming up, but for now, here are the allowable ranges for each technique:

  • percentage—0% to 100% for each color

  • integer—0 to 255 for each color

  • hexadecimal—00 to ff for each color

RGB Values with Percentages

To specify an RGB value with percentages, use this format:

rgb(red-percent, green-percent, blue-percent)

Each percent value must be between 0% and 100%. Here’s an example class selector rule that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required