CSS/Properties/color/RGB

From W3C Wiki
< CSS‎ | Properties‎ | color
Revision as of 21:52, 21 July 2011 by Plehegar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

RGB(Red-Green-Blue)

The RGB color model is used in numerical color specifications.

The format of the RGB Value

  • #rgb
    The format of an RGB value in hexadecimal notation is a ‘#’ immediately followed by three hexadecimal characters(0-9, A-F).


  • #rrggbb
    The format of an RGB value in hexadecimal notation is a ‘#’ immediately followed by six hexadecimal characters(0-9, A-F).


  • rgb(R,G,B) -integer-
    The format of an RGB value in the functional notation is ‘rgb(’ followed by a comma-separated list of three numerical values (three integer values(0-255, 0-255, 0-255)) followed by ‘)’.


  • rgb(R,G,B) -percentage-
    The format of an RGB value in the functional notation is ‘rgb(’ followed by a comma-separated list of three numerical values (three percentage values(0%-100%, 0%-100%, 0%-100%)) followed by ‘)’.


Example

  • Some examples are as follow:
#rgb#rrggbbrgb(integer)rgb(percentage)Color
#000#000000rgb(0,0,0)rgb(0%,0%,0%) 
#FFF#FFFFFFrgb(255,255,255)rgb(100%,100%,100%) 
#F00#FF0000rgb(255,0,0)rgb(100%,0%,0%) 
#0F0#00FF00rgb(0,255,0)rgb(0%,100%,0%) 
#00F#0000FFrgb(0,0,255)rgb(0%,0%,100%) 


Point, Note

  • Values outside the device gamut should be clipped or mapped into the gamut when the gamut is known: the red, green, and blue values must be changed to fall within the range supported by the device.
em { color: rgb(255,0,0) }       /* integer range 0 - 255 */
em { color: rgb(300,0,0) }       /* clipped to rgb(255,0,0) */
em { color: rgb(255,-10,0) }     /* clipped to rgb(255,0,0) */
em { color: rgb(110%, 0%, 0%) }  /* clipped to rgb(100%,0%,0%) */


CSS Reference

CSS Color defines the RGB color values in 4.2.1. RGB color values.