CSS: RGB Color
RGB Hexadecimal Syntax
The RGB color model uses 3 values, for {Red, Green, Blue}, each with a value range from 0 to 255, in 2 Hexadecimal digits.
p { color: #ffc0cb }
ff
is decimal 255c0
is decimal 192cb
is decimal 203
〔see Binary/Hexadecimal Converter〕
RGB Hexadecimal Syntax Shortcut
When using hexadecimal, if digit for each value are repeated, it can be abbreviated to just 3 hexadecimal digits. Like this:
color: #0f7
same as
color: #00ff77
RGB Integer Syntax
RGB color by integer, 0 to 255
p { color: rgb(255, 192, 203) }
RGB Percent Syntax
p { color: rgb(100%, 75%, 79%) }
Opacity RGB Syntax
rgba(red, green, blue, opacity)
- red green blue each can either be a integer from
0
to255
, or a percentage from0%
to100%
. - opacity should be from 0 to 1.
Example
p.x { color: rgb(255, 192, 203, 0.5) }
p.y { color: rgb(100%, 75%, 79%, 0.5) }